• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Making a page expire

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry about that, correction made.
 
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic