Karin Schellner wrote:
I am new to Struts and would appreciate your ideas for a solution to the
following problem:
In my webapplication I have a login-form with a submit and cancel
button. When the user clicks the cancel-button I would like to return
him to the page he previously visited (before calling the page with the
login-form). Using a forward in the action-mapping would redirect the
user always to the same page (e.g. welcome.do), therefore I was thinking
of storing the last visited page in the session and use it for a
redirect, but then I would bypass the struts-config ... what do you
think? Is there a possibility to achieve this in Struts?
The second option is the one you want. There's no way you can statically
define a forward in struts-config that points to 'the page the user was on
before this one'.
What you could do, though, is create a ReturnToPreviousPage action which
redirects to the URL you stored in the session and have an action forward
in struts-config pointing to that action. You still have to keep track of
where that action should redirect to yourself (though the session or
whatever). The advantage is that your struts-config is still declaratively
declaring the behaviour -- and you can then change the behaviour (e.g. to
always forward to the application home page instead of the previous page)
by modifying the config. You also get the option to re-use the
ReturnToPreviousPage action anywhere else you need the same behaviour.
HTH,
L.
--
Laurie Harper
Open Source advocate, Java geek: http://www.holoweb.net/laurie
Founder, Zotech Software: http://www.zotechsoftware.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]