This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes Dynamic redirection in struts 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 » Java » JSP
Bookmark "Dynamic redirection in struts" Watch "Dynamic redirection in struts" New topic

Dynamic redirection in struts

Ranadhir Nag
Ranch Hand

Joined: Mar 09, 2006
Posts: 138
We have a listings page which contain links for different actions.Each of those actions would require a user login before proceeding to the respective jsp page.

How do we dynamically pass in the input action/page to the login action.
On successul login,we need to redirect to that particular action/page from where the login action was triggered.

If this is not possible dynamically then we need to define separate actions for login from each of the page which requires a logged-in user.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60800

Store the original URL in order to redirect to it after login. You could store it in the session or in a hidden parameter that gets carried along.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Stefan Evans

Joined: Jul 06, 2005
Posts: 1016
Certainly you can do that. In fact if you use Tomcat's inbuild security it does it automagically for you.

The basic idea is that you remember which page you were heading to when you triggered the login (eg storing it in session) and then head to that page once login succeeds.

The simplest way I could think of doing it would be to store the relevant "success" actionForward in session, and return that actionForward from your login action. Of course that might be oversimplifying things.

You might get more luck in the struts specific forum.
I agree. Here's the link:
subject: Dynamic redirection in struts
Similar Threads
Dynamic redirection in struts
MVC without Struts: A doubt
extra blank lines appearing on page on using tiles
Call Actions in a different module from default module
Dynamic redirection in struts