• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Making a page expire

 
Jim Carey
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like the page to expire when the back button is pressed so the message "Warning: Page has Expired etc" appears. I have found some suggestions in this forum and applied them, their not working for me, so I must be doing something wrong. I have tried the following response header combinations"

<% response.setHeader("Cache-Control", "no-cache");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("max-age", 0);
response.setDateHeader("Expires", 0);%>


<%response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);%>


<%response.setHeader("Cache-Control","no-cache");
response.setHeader("Expires", "0");
response.setHeader("Pragma", "No-cache");
response.addHeader("Cache-control", "no-store");
response.addHeader("Cache-control", "max-age=0"); %>

I am new to JSPs & servlets, any help you can provide is greatly appreciated. Thanks in advance.

Sincerely
Jim Carey
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64961
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"nocljhc",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
Jim Carey
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about that, correction made.
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I would like the page to expire when the back button is pressed


Controlling browser back button from server code is not possible. You got to use sessions(after proper authentication)along with response header to prevent restricted resources from being accessed by un-authenticated users.

[ December 09, 2005: Message edited by: Vishnu Prakash ]
[ December 09, 2005: Message edited by: Vishnu Prakash ]
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use those response header in order to tell the browser that please dont cache the page. But it might not work with all browsers. I guess it doesn't work with IE.

Otherwise, if back button just work like a new request, then you can do as Vishnu already said that you need to use session for this. After a successful login you can put the user bean into session and then check for that in session if found then OK otherwise redirect to login page.

Thanks.
 
Jim Carey
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for replying.
I understand that I can create a session object to track the users activity and can redirect them when they reach a stale page. However I would like to pursue the Page expired message when the user moves back to a stale page. Is there some other technology involved beyond setting response headers in a JSP or Servlet that cause this to occur? I am running IE 6.0, I see the "page expired" message frequently on my machine. I am doing this for a school project.

Thanks in advance
Sincerely
Jim Carey
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic