Skip to content

Repository files navigation

JSP-Example

Servlet – HttpSession Login and Logout Example

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.


📌 Project Overview

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

🛠 Technologies Used

  • Java (JDK 8+)
  • Java Servlets
  • JSP
  • Apache Tomcat Server
  • Eclipse IDE
  • HTML

📂 Project Structure

LoginLogout_Servlet
│
├── src
│   ├── RequestServlet.java
│   └── ResponseServlet.java
│
├── WebContent
│   ├── login.jsp
│   ├── welcome.jsp
│   └── WEB-INF
│
└── web.xml

⚙️ Application Flow

  1. User opens login.jsp

  2. Enters username and password

  3. LoginServlet

    • Validates credentials
    • Creates HttpSession
    • Stores username in session
  4. User is redirected to welcome.jsp

  5. User clicks Logout

  6. LogoutServlet

    • Invalidates session
    • Redirects back to login page

📸 Screenshots

🔐 Login with Welcome Page

Login Page

Password wrong then show this

Logout Page

🚪 Logout

Logout Page


✅ Features

  • Session-based authentication
  • Secure logout using session invalidation
  • Simple and beginner-friendly
  • Useful for academic & interview preparation

📚 Learning Outcome

  • Understanding HttpSession lifecycle
  • Session creation and destruction
  • Login and logout flow using Servlets
  • JSP and Servlet interaction

🧠 Reference


⭐ If you like this project, don’t forget to star the repository!

About

A Java Servlet-based Login and Logout application demonstrating user authentication, HttpSession management, session handling, and secure session invalidation.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages