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 How to handle back button caching Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to handle back button caching" Watch "How to handle back button caching" New topic
Author

How to handle back button caching

abhinav singhal
Greenhorn

Joined: Jun 19, 2003
Posts: 29
Hi All,

I have earlier posted the topic regarding the session handling. But, right now I am facing the major issue with the back button handling or we can say Caching. I am using the below mentioned code:

response.setHeader("Cache-Control","no-store"); //HTTP 1.1
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma\"","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
JSPsession.invalidate();

And then I am forwarding to next JSP. But on pressing the back button I am still getting the older page. PLease guide me how to handle this situation.

Basically I have to logout from the session and do not want to enter the previous page.

Thanks and Regards,
Abhinav Singhal
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026

And then I am forwarding to next JSP. But on pressing the back button I am still getting the older page. PLease guide me how to handle this situation.


Cache-Control headers alone will not help you here. If the user is in session(logged-in) and if he uses back-browser button he can view the pages.


Basically I have to logout from the session and do not want to enter the previous page.


You got use session methods here. session.invalidate() will invalidate the current session of the client. If the user directly enter the URL to retricted resource in your application then your application logic should handle it. Like get the user name/password and store it in session as an attribute and verfify it in every restricted page.

Example:

Servlet code:


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to handle back button caching
 
Similar Threads
Cache or Server query
I need help on developing login/logout application using struts2 frame work
Dealing with back buttons
Preventing Old page to get loaded
JSP image caching problem