3

I have a web application running on a WebSphere v8.5 server instance. I have just updated shared code in the applications JSPs to a separate JSP and imported into the original JSP using this line:

   <%@ include file="/WEB-INF/pages/table.jsp" %>

However whenever I make modifications to the back end logic or to this table.jsp file the changes are reflected in in the application. I have tried restarting the server and doing clean builds but the old formatting remains. Does anyone know how I fix this caching or how I prevent it from continuing to happen?

JBMac
  • 329
  • 1
  • 6
  • 18
  • 1
    Try `` that include the content at run-time whereas include page directive performs at compile time. – Braj Jun 11 '14 at 21:21
  • Have you tried it again after clearing browser caching? Read more here [Making sure a web page is not cached, across all browsers](http://stackoverflow.com/questions/49547/making-sure-a-web-page-is-not-cached-across-all-browsers) – Braj Jun 11 '14 at 21:23
  • Try with ` ` – Braj Jun 11 '14 at 21:25
  • I have tried all of these: cause format issues that were extremely crazy nothing resembled what it was suppose to be. THe browser clears cache on exit, but company standards for those without access prevents browser setting to be modified. I have include the no cache tags on all jsp pages but again no avail. The only thing that has fixed it is to delete the server instance and create a new one and this is a process that takes to much time for modifying intricate alignment pixel by pixel. – JBMac Jun 11 '14 at 21:39
  • A final hint that works always. Simply append a random query parameter such as current time in milliseconds or UUId in the JSP URLs that will force the browser to fetch new copy of the resources because URL has been changed. – Braj Jun 11 '14 at 21:57
  • I found another tag it is suppose to work like the will definitely report if things work. – JBMac Jun 11 '14 at 22:16
  • yes its JSTL tag works in the same way. – Braj Jun 11 '14 at 22:16
  • So the worked just like the JSP:include tag and the table had no form no was able to retrieve data from from the business level controllers. i will have o stick with the chace files and keep researching. – JBMac Jun 11 '14 at 22:23
  • Keep reading If nothing works then I have given you a final hint. – Braj Jun 11 '14 at 22:25

3 Answers3

9

<%@ include file="/WEB-INF/pages/table.jsp" %> is a static import, so it includes contents of the table.jsp file into your parent jsp before the parent is compiled. After parent is compiled, changes to the table.jsp will not be visible, as parent source/class will not change. You have to update timestamp (e.g. use touch command or open and save) on the parent to make container be aware that changes have been done in the included files.

Gas
  • 17,601
  • 4
  • 46
  • 93
  • I try to add a timestamp parameter to it <%@ include file="/WEB-INF/pages/table.jsp?time=${timestamp}" %> however whenever i try to load the page it give me an error saying that it cannot find the page, do you know how do I add a parameter to this import tag? – JBMac Jun 12 '14 at 13:29
  • so the application has a great deal of exposed beans and model attributes that get applied in the compile-time include (<%@ include %>) however when I try the jsp:include or even there are issues that the table.jsp cannot access the exposed bean or model attribute in order to format properly. So without over hauling do to deadlines (tomorrow), I need a way to keep this file un-cached without having to delete the server instance. – JBMac Jun 12 '14 at 14:20
  • Why would you like to delete server??? Undeploying app would be enough. And file is not cached. jsp:include or c:import won't work, if you have jsp fragment as it expects full jsp file. As I told you, refresh modified date on your parent jsp file. You can do it for all jsp files in your project: On unix do: $ find . -name "*.jsp" -exec touch {} + On Win do: powershell gci -recu -inc "*.jsp" | % { $_.LastWriteTime = Get-Date } – Gas Jun 12 '14 at 15:51
  • Ok I misunderstood you first post for the approach should the command be performed from the parent JSP or will I have to write a scheduled job to perform it? – JBMac Jun 12 '14 at 17:54
  • In general you should update your application using admin tools (console, scripting or monitored directory). Behavior you are describing is only possible, if you manually modify jsp files on already installed on server application. So if you do this, create some system script, which will refresh timestamp on jsp files, and call it whenever you change jsp. Or maybe I dont understand your deployment scenario. – Gas Jun 12 '14 at 22:47
0

The WAS does cache the JSP files in the profile-root/temp folder. erase the content of this folder and it should refresh with the new JSP files.

For a more permanent solution please see this link: https://developer.ibm.com/answers/questions/180818/how-to-resolve-jsp-caching-issue-in-websphere-appl.html

Ricardo
  • 11
0

Add this custom property com.ibm.ws.cdi.enableCDI to false under Java Virtual Machine. This will disable CDI and enable JSP reload without application or server restart.

Kuppusamy
  • 65
  • 1
  • 6
  • How did you get the idea that disabling CDI has anything to do with jsp reload??? – Gas Nov 09 '18 at 12:13
  • Refer to this http://www-01.ibm.com/support/docview.wss?uid=swg1PI58316 Don't downvote if more information is needed. This issue i fixed for my colleague and tested working. This fix is apart from standard configuration to reload JSPs using autoreload flag and interval. We tried deleting the war file contents in temp folder too. Nothing worked. This fix can be applied if CDI is not used in any of the application deployed in the server. – Kuppusamy Nov 10 '18 at 08:07
  • Please,next time, make sure you are providing link to source for such information, or provide full information, as your post is misleading. First of all it is related to WebSphere Liberty, not traditional WAS, second information in the link tells that it was a bug, which is fixed in recent versions. So the solution is to update the version, not disable the CDI. – Gas Nov 10 '18 at 08:49