This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The browser back-button problem

 
Gezza Hall
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1258
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
s penumudi
Ranch Hand
Posts: 113
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 113
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 415
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1312
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic