aspose file tools*
The moose likes Struts and the fly likes request.getRequestDispatcher in Action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "request.getRequestDispatcher in Action" Watch "request.getRequestDispatcher in Action" New topic
Author

request.getRequestDispatcher in Action

Jordan Smith
Ranch Hand

Joined: Apr 06, 2008
Posts: 89
Hi
I have a LoginAction that should be executed when the user submits his name and password.
The thing is that the user may arrive from many pages to this login page.
what is the best way to forward him?
i was thinking of creating a mid-form with jsp:forward tag.
is there a way to do it in action class?
because it has to return ActionForward and

is void!
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
what is the best way to forward him?


Please explain this question.
Jordan Smith
Ranch Hand

Joined: Apr 06, 2008
Posts: 89
to forward the user the the url that he came from
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Actions that forward, stream the response, etc. should return null.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
The thing is that the user may arrive from many pages to this login page.
what is the best way to forward him?


You could define one or more global forwards that go to each page that uses the login page.



Then include a hidden variable in the form (the one that user uses to submit name and password) that identifies which page is sending the request.



In the LoginAction, after authenticating the user, determine which page sent the request by reading the hidden variable and then using the global forward, get the user to any page you want them to go to. Sending them back to the page where they just entered their user name and password does not make any sense, however.


[ December 24, 2008: Message edited by: James Clark ]
shaf maff
Ranch Hand

Joined: Sep 07, 2008
Posts: 180
How would you do that for struts 2 ? I tried it and the return mapping didnt work..
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

@Shaf: http://struts.apache.org/2.x/docs/parameters-in-configuration-results.html
shaf maff
Ranch Hand

Joined: Sep 07, 2008
Posts: 180
Thanks david!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: request.getRequestDispatcher in Action
 
Similar Threads
ResultSet from Servlet to JSP
radion button input in form
Application flow
IllegalStateException: Cannot Forward(Servlet 2.3, SRV 8.4)
Not able to forward servlet to