aspose file tools*
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
Author

session cahe

Sam Anjos
Greenhorn

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
Greenhorn

Joined: Aug 24, 2002
Posts: 14
Sam,
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
request.setAttribute("someObj")=null
}
else
{
response.redirect("tosomepage")
//or do whatever action u want here to prevent refresh
}
Try this it will work

njoi
 
wood burning stoves
 
subject: session cahe