This project demonstrates a basic Login and Logout system using Java Servlets and HttpSession. It shows how to create, manage, and invalidate user sessions in a Servlet-based web applications.
Managing user sessions is essential in web applications to track user login status across multiple requests. In this project, HttpSession is used to:
- Store user login information
- Restrict access to secured pages
- Destroy session data on logout
- Java (JDK 8+)
- Java Servlets
- JSP
- Apache Tomcat Server
- Eclipse IDE
- HTML
LoginLogout_Servlet
│
├── src
│ ├── RequestServlet.java
│ └── ResponseServlet.java
│
├── WebContent
│ ├── login.jsp
│ ├── welcome.jsp
│ └── WEB-INF
│
└── web.xml
-
User opens login.jsp
-
Enters username and password
-
LoginServlet
- Validates credentials
- Creates HttpSession
- Stores username in session
-
User is redirected to welcome.jsp
-
User clicks Logout
-
LogoutServlet
- Invalidates session
- Redirects back to login page
- Session-based authentication
- Secure logout using session invalidation
- Simple and beginner-friendly
- Useful for academic & interview preparation
- Understanding HttpSession lifecycle
- Session creation and destruction
- Login and logout flow using Servlets
- JSP and Servlet interaction
-
Oracle Java Servlet Documentation https://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpSession.html
-
Apache Tomcat Documentation https://tomcat.apache.org/


