File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Page expired message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Page expired message" Watch "Page expired message" New topic
Author

Page expired message

Nithya Krish
Greenhorn

Joined: Dec 09, 2004
Posts: 5
Hi,
In my project we are using JSPs. When someone clicks on the back button, the "page expired" message appears and we need to refresh to access that page. I have even set the cache as public to see if it fixes the problem and that doesn't seem to work. Appreciate any help!
Thanks,
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

"Nithya RK",

We're pleased to have you here with us in the JSP forum, but there are a few rules that need to be followed, and one is that proper names are required. 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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Srinivas Krishna
Greenhorn

Joined: Dec 10, 2004
Posts: 8
hi nithya,

u check it out that ur using any sessions in ur jsp page.
session plays a very important role in page expiration

fortune favours the brave


Srinivas Krishna
Rajendar Goud
Ranch Hand

Joined: Mar 06, 2002
Posts: 220
Hi Nitya,
As srinivas said,check out for session variables,and if they are not present then you can define session variables which allows you to retain the previous page from where you had been accessing.
if you just want to get back and doesnt want to retain data,write a javascript function and call history.back(-1).

-Raj
Nithya Krish
Greenhorn

Joined: Dec 09, 2004
Posts: 5
Hi,
Firstly, Thank you for your suggestions!
I added a session variable(We have not used session variables so far) to the header tile which is used across the pages of the site. But the "page expired" message still comes when we hit the back button. Could this problem be because we are using tiles?
The history.back behaves like the back button i.e. does not hit the server but displays the "page expired" message and asks the users to click refresh if they want to see the page.
Appreciate any help!
Rajendar Goud
Ranch Hand

Joined: Mar 06, 2002
Posts: 220
Nitya,
i am not much into tiles,but can say that its not related with using tiles.you mentioned that you created a session variable which is accessible across all pages,but what are you using that session variable for. you need to check that session variable value when ever you click back ,ie when the page is submitted.

-Raj
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I may be off base here ... is this happening because the page you want to go back to was populated by a POST? I see the same message when I try to refresh such a page. If you're posting a search form look into converting to JavaScript that resets the source of the page to do a get. If you're posting an update form you can try to use a Post-Redirect-Get pattern.

The user is always looking at pages created by GET so the refresh button works fine.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Nithya Krish
Greenhorn

Joined: Dec 09, 2004
Posts: 5
Hi Raj.I have not used any session variables in our project so far. I just added one to see if that fixes this problem. What I did was:
I set the session variable to the users Id when someone enters the site. And in the header JSP I just do a System.out.println on that value. I notice when I click the back button, the browser does not even hit server. It just directly shows the "page expired" message

Yes, Stan. It is a post form and it works fine when I use get method. Is there some way I can solve this without a get? Because every page in this site is a JSP and in some pages, the number of form elements are huge.
I am not sure I can use the Post-Redirect-Get pattern here. Is there some other way?
Nithya Krish
Greenhorn

Joined: Dec 09, 2004
Posts: 5
Am posting what worked for me in case it might assist someone else:

response.setHeader("Cache-Control", "private");
response.setHeader("Vary", "User-Agent");
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Page expired message
 
Similar Threads
Session time out error
Page cannot be displayed if we press back button
back to page problem
Automatic Redirect to Login page on Session Expire
How to invoke a method when back button in browser is clicked.