GeeCON Prague 2014*
The moose likes Servlets and the fly likes Best way for forwarding request after login Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Best way for forwarding request after login" Watch "Best way for forwarding request after login" New topic
Author

Best way for forwarding request after login

Ashraf Fouad
Ranch Hand

Joined: Oct 07, 2001
Posts: 80
Dears,
I'm sending emails from my application to the users of the application, these emails contain URLs to specific pages with different parameters, but my application requires login before anyone can view or make action.

So I will need to check if the user in session if not, forward to login page with the required parameters, then the login page submits to me after login as defined in the email.

What is the best solution for this situation, I'm using Struts 1.1 on SUNONE 7 application server, if provided code samples it will be great.

Thanks


Ashraf Fouad
SCJP 1.2, SCBCD 5
Shraga van Shufel
Ranch Hand

Joined: Apr 20, 2003
Posts: 33
Hello,

If I understand correctly you would like the users to reach a certain URI (an action in your case), if the user can not be found in the session the user will be forwarded to the login page and after successful authentication will be send to the original desired action.

You can achieve it using the following:
* In your target action check if user exist in the session
* If not use the request methods (getRequestURI, getQueryString) to build a url and assign it to the session
* forward the user to the login action
* After the user got authenticated check if your session contained the url reference you submit in your actual action.
* If the reference exist then create a new Action forward and assign it the url, if not send it to the original page you sending the users after login.

Hope it helps
/Shraga.
 
GeeCON Prague 2014
 
subject: Best way for forwarding request after login