I have a java server, when I change something within the JSP
code, and I call the page again from the browser, my changes are not shown, the server ret开发者_JAVA技巧urns the old JSP
.
Any one has idea why?
The Jasper How-to tells that in conf/web.xml
, for your org.apache.jasper.servlet.JspServlet
you need:
development
- Is Jasper used in development mode? If true, the frequency at which JSPs are checked for modification may be specified via the modificationTestInterval parameter.true or false, default true.checkInterval
- If development is false and checkInterval is greater than zero, background compiles are enabled. checkInterval is the time in seconds between checks to see if a JSP page (and its dependent files) needs to be recompiled. Default 0 seconds.
The <Context>
element has the following properties:
reloadable
- set to true if you want hot-deployment of classes and libs in addition to jsp filesantiResourceLocking
- should be false
All the above was about the server. Client-side caching is another reason why you may not see newer version of pages. Simply hitting CTRL+R / CTRL + F5 often suffices.
Deciding your cache strategy is something different, and a different topic - what resources would you tell the browser to cache, and for how long. Preferably you should put the cache headers - Expires
and Cache-Control
(and Pragma
) in a common location in your application, where you can change it quickly.
You can also stop the application (using Tomcat WebApp Manager), and delete the app's "work" folder in the tomcat directory. This will force tomcat to rebuild the cache files using the new JSPs.
The path to the folder with cache files is something like this: /usr/apache-tomcat-XXX/work/Catalina/localhost/
Just delete the folder with your app's name, and restart the app.
You can try doing 2 things:
Set <context-param>
tag in web.xml
<context-param>
<param-name>weblogic.jsp.pageCheckSeconds</param-name>
<param-value>0</param-value>
</context-param>
In you Jsp page at the top:
<%
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0);
%>
精彩评论