permaculture playing cards*
The moose likes Struts and the fly likes The browser back-button problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "The browser back-button problem" Watch "The browser back-button problem" New topic
Author

The browser back-button problem

Gezza Hall
Ranch Hand

Joined: Jan 04, 2005
Posts: 33
Hi all.

I have the problem where if I press the back-button, the page has expired and needs to be refreshed to load. I don't want this behaviour on my application.

I've seen this topic mentioned on messageboards everywhere, but as this is purely a struts form-based app, thought I would post it here.

Some have said that this happens because the form is submitted POST - but I assume that I can't change that with struts?

Anyone know how I can avoid this happening?

Thanks!
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
You could always do GETs instead of POSTs, but that may not be reasonable or possible. Also possible: tell the user not to use the back button on their browser, and instead create a back button for them that POSTs the information to the correct place. Maybe.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
s penumudi
Ranch Hand

Joined: Nov 17, 2004
Posts: 113
Check if you have any of these properties set either in your JSP or Action classes.

response.setHeader("Cache-Control","no-store"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
Gezza Hall
Ranch Hand

Joined: Jan 04, 2005
Posts: 33
Originally posted by s penumudi:
Check if you have any of these properties set either in your JSP or Action classes.

response.setHeader("Cache-Control","no-store"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server


Sorry, are you saying that these SHOULD or SHOULD NOT be present for the action that I want? Thanks!
s penumudi
Ranch Hand

Joined: Nov 17, 2004
Posts: 113
Sorry they should not present.

Those tags means that the browser should not cache JSP content.Hence page expiration shows up when you hit back button
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Hi

This happens even if u place cahce code tags in ur jsp or action class .because when the user cliks back a new req will be passed and its the browser bahviour to warn u if there is some post data ..........this can be avoided by making the response GET immediately after perfomring the post operation ...i mean to say when u write ur forward after the post place redirect="true" .........but the problem with this is ur request attributes get lost as the clinet makes a round trip ......so u can place the necessary data in Session if u want
Ivy Kho
Greenhorn

Joined: Oct 20, 2004
Posts: 17
Originally posted by s penumudi:

response.setHeader("Cache-Control","no-store"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server


supposing i add those 3 lines in my jsp page and the user clicks on the back button, will it automatically reload the page by itself or will the user only see the page refresh section?
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
By default :: show the page has expired .

BUT it's some action such as save, update, delete , it's must to do follow lastest action (occured error in your application).


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The browser back-button problem
 
Similar Threads
[Help, File Upload encounter OutOfMemoryError]
Back button solution
No validation before LookupDispatchAction
Back button behaviour
My First Struts App