struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sébastien Domergue <>
Subject Re: S2: Forward or Redirect to same page
Date Wed, 10 Dec 2008 09:08:05 GMT

we had nearly the same problem in a project and we had to build our own 
stack (which contained both action and jsp names) and when we wanted to 
go back we used the stack. Nevertheless, i don't think you need to keep 
the whole stack and you could give the jsp name as a parameter of your 
form (by a hidden field for exemple). In your action, the attribute must 
have a setter and a getter and, in your struts.xml you coul use a result 
of this kind :

<result name="myResultName">${myAttribute}</result>

if 'myAttribute' contains a string that points to your jsp then the jsp 
will be displayed again.



Dirk Forchel a écrit :
> I have a problem forwarding to the same page after a request is submitted by
> a form. This could be straightforward until this form is only on the same
> page. In this case I would use a "dispatcher" to forward to the appropriate
> JSP. But how can I forward to the "same page" if I use the same form on
> different pages?
> How do I forward to the same page I was coming from? The typical example for
> this is to change the language of a website with a "change-language-form".
> Someone is on one page and simply wants to change the language and expects
> to see the same page with the different language selected. Another case
> could be a login-form displayed. No matter when the login is performed, the
> user will be returned to the same page he has been before. A similiar case
> could be a "search-form" where the user types in a search term. If
> validation fails for a non-existing term, the Workflow-Interceptor expects
> an "input"-result where to forward. But this "input"-result is different to
> all pages including this search-form.
> Exists something like a "request"-history (a stack of all forward-requests)
> in Struts2?

View raw message