File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes problem in Servlets and JSP's Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem in Servlets and JSP Watch "problem in Servlets and JSP New topic
Author

problem in Servlets and JSP's

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
i am into web development in java. 'm using java web server2.0 as my web server .
i have developed my site with servlets and jsp's ..
when i try accessing a JSP or servlet..the file existing in my cache is displayed(the htm already generated my the servlets and jsp's exist in cache)..instead of going to server and fetching the file and displaying..
how to avoid this..to be very straight ..
what is the equivalent of response.expires(ASP) in java servlets..?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
Since the cache is on your browser you need HTTP cache control. This came up recently in the Tomcat mail list and somebody replied as follows:
"In my opinion, it is a cache problem.
This lines might help you.
<%
response.setHeader("Expires", "Mon, 26 Jul 1990 05:00:00 GMT");
// Date in the past
response.setHeader("Cache-Control" ,"no-cache, must-revalidate");
// HTTP/1.1
response.setHeader("Pragma", "no-cache");
// HTTP/1.0
%>
"
I have not tried this but you get the idea. Your servlet or JSP has to tell your browser not to cache this page.
Bill
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Murali...
seems like I am also facing same problem ...if you have any
input to make pls. do so.
hope u were able to solve ur problem???
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
You should note that this is a problem with AOL as AOL does not promise to honor expires or no-cache requests in their own caching (not the browser's cache but AOL's own cache). The only way to insure that AOL will not cache a page is to add a variable to the URL:
/servlet/MyServlet?dummy=123


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
This is a common problem across many browsers the best remedy would be to put it in the HTML itself rather than the Scriptlet.
put the following code in the head section of the webpage
<META HTTP-EQUIV = "Pragma" CONTENT="no-cache">
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
The point I was trying to make is that AOL's own caching (not the browser cache) does not guarantee that it will honor a no-cache request. AOL gets so many hits for the same sites that they do their own caching rather than go back to the internet to reload a site for user B that they just sent to user A. The only way to get AOL to guarantee to reload a page is to either a) have cgi-bin/ in the URL or b) have a parameter in the URL (/servlet/MyServlet?Dummy=123)
Ganesh Anekar
Ranch Hand

Joined: May 13, 2001
Posts: 36
Hello,
If u r using IE5 check the settings for history.
same things for netscape also...
In these both browsers there is settings for session control and page visit ...check that also..it will work...
Close the browser and clear the tmp dir of javawebserver then reopen the same file u will get the proper result...
Ganesh

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in Servlets and JSP's