How do I find if the current user has logged in or not
Abhishek Asthana
Ranch Hand
Joined: Sep 08, 2004
Posts: 146
posted
0
Hi, I have made an online shopping store using Servlets,JSP and EJBs. I want that when user presses 'Add to Cart' button for the first time, he is shown login page, where he has to login and every other time he is shown the shopping cart page. How do I find if the current user has logged in or not? Please tell me. I am using JBoss 3.2.1. Abhishek
Tom Griffith
Ranch Hand
Joined: Aug 06, 2004
Posts: 256
posted
0
How about setting a session attribute upon successful login and then on all the jsp's, use an if statement to see if that particular session attribute has been set. If it's null, forward them to the login screen. You have to watch for session timeouts.
Valentin Tanase
Ranch Hand
Joined: Feb 17, 2005
Posts: 704
posted
0
Hi Abhishek,
You might need to specify one more thing though: are you using implicit J2EE security, or your application implements the security logic (explicit security). If you�re going with the second approach, then Tom already provided you the solution. Otherwise just let me know if you need further assistance. Regards.