File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to control cached pages?

 
Rui Ferns
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
My problem is,I want to know how to stop users from seeing previous pages by using the back button. Like if someone fills out form fields and then submits and leaves the PC and then another user comes along and hits the back button then they can see all the past users sensitive info in the form fields.
It seems the browser is retrieving the cached pages.How can I stop this from happening. I'd like to have it that if a person tried to hit the back button then they are taken to a warning page telling them that they can't view this page and give them a link to the start page.
I've tried various methods to solve this problem but none seem to work properly.
Could anyone tell me how to tell a jsp not to use the cached pages?
thanks
Rui
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use the pragma no-cache meta tag. It seems to work fine. From memory, I think the tag goes something like:
<html>
<head>
<meta param="pragma" value="no-cache">

I think
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you use the meta tag if you can set the response headers directly?
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "0");
- Peter
 
Mark Simms
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%
response.addHeader("Pragma", "NoCache");
response.addHeader("Cache-Control", "no-cache");
response.addDateHeader("Expires", 1);
%>
The official way is above......
be sure to warn users of the warning message they will get from their browsers....
 
Rui Ferns
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I tried that and it still isn't working.
I must be doing something wrong.
Where exactly should I put the code you gave?
Should it be in the page I want not to be cached?
So when the user presses the back button this page doesn't appear?
thanks
Rui
Originally posted by Mark Simms:
<%
response.addHeader("Pragma", "NoCache");
response.addHeader("Cache-Control", "no-cache");
response.addDateHeader("Expires", 1);
%>
The official way is above......
be sure to warn users of the warning message they will get from their browsers....

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic