Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

request.getRequestDispatcher in Action

 
Jordan Smith
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the best way to forward him?


Please explain this question.
 
Jordan Smith
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to forward the user the the url that he came from
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actions that forward, stream the response, etc. should return null.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would you do that for struts 2 ? I tried it and the return mapping didnt work..
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
 
shaf maff
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks david!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic