Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Page expired message

 
Nithya Krish
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
Srinivas Krishna
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rajendar Goud
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Nithya Krish
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am posting what worked for me in case it might assist someone else:

response.setHeader("Cache-Control", "private");
response.setHeader("Vary", "User-Agent");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic