tags:

views:

698

answers:

2

I have inherited a Java website that uses Struts 1. Currently if the brosers back button is pressed midway through a journey they get a 'Webpage has expired' error.

From my limited understanding, this seems to be a flaw in the design of Struts - every page is a form. Is there anyway to get around the problem, or would the only way be migrating to a different MVC framework (struts2, springMVC)?

+1  A: 

I don't think there's anything inherent in struts that does that. It sounds like the previous developer tried to create some kind of wizard. The proper way to do it, would be to store the pending results in the wizard in a session, and do a full redirect after every form submission.

blockhead
Yes its like a wizard, a series of pages 1->2->3->4->5->6However page 2 relies on the data from form 1.What do you mean by 'a full redirect after every form submission'?
Amoeba
In most MVC frameworks, as the result of any action, you could either forward to another action or do a redirect. A redirect means that the server tells the browser to physically go to another page. This is what is commonly known as the POST-REDIRECT-GET pattern (http://en.wikipedia.org/wiki/Post/Redirect/Get). For more info on this see this: http://stackoverflow.com/questions/614516/why-use-redirecttrue-in-struts-1-forwardI think that will help clear up some things.
blockhead
+4  A: 

This is not a Struts problem, really. Apparently, the guy who built this did not believe in the Post/Redirect/Get pattern, and instead serves up a page directly in response to a form submission.

You can change this behavior by applying redirect="true" to your action forwards:

<action ... >
   <forward name="success"
       contextRelative="true"
       path="/moduleB/index.do"
       redirect="true"/>
</action>

See the Struts user guide for more information.

Henning