Free Jobs

Java Forums: Core Java (15) J2EE (3) EJB (5) Servlet (3) JDBC (6) Hibernate (2) Struts (1) Swing (1) Oracle (7) JSP (4) Other (10)

Topic: How to create Login and Logout for users using session in java and JSP

To get the Posted Questions details daily in your mail Click Here

Share this Post on Facebook/Twitter/Orkut Bookmark and Share

User: mohit555 Post Date: 23 Jan 2012 09:38

How to create Login and Logout for users using session in java and JSP

Main Content:

The general way to do this is setting the session with user name

when user signs in and invalidating the session once user logs out.

The code for creating username session on login is as below:

HttpSession sessionObj=request.getSession(true);


The code for checking username session on any page is as below:

Object sessionObj=(session.getAttribute("Name"));

String sessionVar=sessionObj.toString();

if (sessionVar != null)


      //display the required page




  <jsp:forward page="ErrorPage.jsp" />


The code to invalidate the session for logout



This way we can create Login and Logout for users using java and JSP

About Writer:
Hi All,I am Java Developer From Bangalore

Writer's Link:

Writer's Email:

Post Comment

Similar Articles Top ArticlesLatest Articles Other Articles by this Author Copyright © 2009-2011 | All Rights Reserved
All content of this website is protected by copyright laws and should not be reproduced in any form or by any means without written permission
(Best viewed in IE 8.0+ or Firefox 3.0+ at resolution of 1024 * 768 or higher)