Best way for forwarding request after login

Ashraf Fouad

Ranch Hand

Posts: 80

posted 13 years ago

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

Posts: 33

posted 13 years ago

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.