aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes How do I find if the current user has logged in or not Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How do I find if the current user has logged in or not" Watch "How do I find if the current user has logged in or not" New topic
Author

How do I find if the current user has logged in or not

Abhishek Asthana
Ranch Hand

Joined: Sep 08, 2004
Posts: 146
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: 257
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
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.


I think, therefore I exist -- Rene Descartes
 
Consider Paul's rocket mass heater.
 
subject: How do I find if the current user has logged in or not