Refresh the Servlet
Dear Friends,
when i refresh the page ,Servlet won't work correctly.
so , i have to ( Every time ) clear the History of IE. is there any way to
avoid this problem ( automatically clear the History in IE ).
[263 byte] By [
thennam] at [2007-11-11 8:01:30]

# 1 Re: Refresh the Servlet
I had a similar problem with my JSP's. Every time I wanted to show the poster of a movie, the first time the poster was correct. The second time, it was still the poster shown the first time.
To avoid this kind of problem, I added the following to my JSP's :
<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Expires", "0");
response.setHeader("Pragma", "No-cache");
response.addHeader("Cache-control", "no-store"); // tell proxy not to cache
response.addHeader("Cache-control", "max-age=0"); // stale right away
%>
Since every JSP is translated to a servlet before being compiled into a class file, I think these lines might help you out.
# 2 Re: Refresh the Servlet
I looked into the code of the servlet which corresponds to the JSP. The lines are translated to
response.setHeader("Cache-Control","no-cache");
response.setHeader("Expires", "0");
response.setHeader("Pragma", "No-cache");
response.addHeader("Cache-control", "no-store"); // tell proxy not to cache
response.addHeader("Cache-control", "max-age=0"); // stale right away
So, they stayed the same when translating the Java Server Page into a servlet.