This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JSP and the fly likes session cahe Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » JSP
Bookmark "session cahe" Watch "session cahe" New topic

session cahe

Sam Anjos

Joined: Jun 06, 2003
Posts: 14
Is it possible to prevent the user from loading a page that has been cached when the browser is refreshed.
This is the code in my page:
<% response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.addDateHeader("Expires", 0); %>
But when the user hits refresh it still loads the form that was there. The biggest problem is that the browser actually tells you to do this.
browser info:
Warning, Page has expired
To resubmit your information and view this Web page, click the Refresh button.

Any help would be appreciated.
Sam Anjos
Rubal Sidhu

Joined: Aug 24, 2002
Posts: 14
I also faced this problem & I used sessions to resolve this.If you want to prevent page to refresh,its better you create a session or use setAttribute() from previous page..& in original page check the session or getattribute() for the first time & display the contents & make it null at the end.Now if you refresh do whatever action you want coz session is null now
the pseudocode should look like this
if(request.getAttribute("someObj")!= null)
//show whatever u want for first time
//or do whatever action u want here to prevent refresh
Try this it will work

I agree. Here's the link:
subject: session cahe
It's not a secret anymore!