Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Basic Servlet session problem

843841Oct 16 2004 — edited Oct 18 2004
Hi all.
I am building a swinf application that communicates with a servlet.
When I submit the username/password to a servlet, it authenticates user and loads another form, main menu.
If the user is valid, the login servlet sets the session like this:
HttpSession session = request.getSession(true);session.setAttribute("userValid", "yes");
When the main menu is loaded, it communicates with another servlet called menu.
this menu servlet checks whether the user has a valid session. I am doing this like this:
HttpSession session = request.getSession();String x = (String)session.getAttribute("userValid");if(x.equals("yes"){//execute codes}
Is this method correct?...how do I check whether the user has already logged in.

Thanks a lot.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 15 2004
Added on Oct 16 2004
8 comments
296 views