Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session cahe

 
Sam Anjos
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic