This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
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.
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.