aspose file tools*
The moose likes JSP and the fly likes Browser back button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Browser back button" Watch "Browser back button" New topic
Author

Browser back button

Neeraj Vij
Ranch Hand

Joined: Nov 25, 2003
Posts: 315
When I click back button in internet explorer, my application gives me a blank page.I get the following message:

Warning: Page has Expired
The page you requested was created using information you submitted in a form. This page is no longer available. As a security precaution, Internet Explorer does not automatically resubmit your information for you

I am using javascript to set the action of form and then submit the form.

I have kept some information in session object also.

I am unable to debug, why this is happening.

Please help..

Thanks,
Neeraj
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Because...The page you requested was created using information you submitted in a form. This page is no longer available. As a security precaution, Internet Explorer does not automatically resubmit your information for you.

More or less because you used javascript to submit the form and now that data is not available when you press the back button.


GenRocket - Experts at Building Test Data
Neeraj Vij
Ranch Hand

Joined: Nov 25, 2003
Posts: 315
what can be done to avoid this except avoiding the javascript.

Thanks,
Neeraj.
Neeraj Vij
Ranch Hand

Joined: Nov 25, 2003
Posts: 315
at my system..i think this is happening on this site also pls. somebody check and correct me..

Thanks,
Neeraj.
Charles Lyons
Author
Ranch Hand

Joined: Mar 27, 2003
Posts: 836
More or less because you used javascript to submit the form and now that data is not available when you press the back button.
This would happen if you had no JavaScript in the page... happens to me all the time when I press back!

By pressing back, you are asking the POST request from your form to be re-submitted to the server. As the original message says, IE warns against this for POST methods only (since POST is non-idempotent) to prevent accidental submission of the data twice. If you really want to submit the data again, you can refresh while on the warning page.

Several patterns have been developed to ensure you don't see this, the most common being the Post/Redirect/Get... in essence it uses a GET redirect so the POST request is 'lost' from the browser's history, thus preventing re-submission of the form. For example, see:

http://www.theserverside.com/patterns/thread.tss?thread_id=20936
http://www.theserverside.com/news/thread.tss?thread_id=29758

I think Bear also wrote an article on this pattern a while ago as well, but I can't find a link to it right now...


Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / Amazon Amazon UK )
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

Article.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
jQuery in Action, 2nd edition
 
subject: Browser back button