Skip to content
TanmayT134Public

About

A Java-based Employee Management System built with Spring MVC, JSP, Hibernate/JPA, and MySQL, featuring admin login and employee CRUD operations.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Employee Management System - Spring MVC, Hibernate, and MySQL

πŸ‘₯ Employee Management System

Manage. Organize. Simplify.

A Java web application built with Spring MVC, JSP, Hibernate/JPA, and MySQL for managing employee records through an admin interface. It supports employee creation, search, updates, and removal, along with admin signup and login pages.

GitHub Repository Java Web Application Spring MVC JSP Hibernate and JPA MySQL Maven


πŸ“– Overview

Employee Management System is a Java-based web application designed to manage employee information through a browser-based interface. The project uses Spring MVC for request handling, JSP for server-rendered pages, Hibernate/JPA for persistence, and MySQL as the relational database.

An administrator can create an account, log in, and access pages for adding, searching, updating, and removing employee records. The application follows a layered structure with Controller, Service, Repository, and Entity packages, making it useful for learning how Spring MVC applications organize request handling and database operations.

The project was developed as an Eclipse/Maven web application. Its current configuration should be reviewed for Java, Spring, Servlet, and Hibernate compatibility before moving to a different runtime or deploying it publicly.


✨ Key Features

πŸ” Admin Pages

  • Admin signup page
  • Admin login page
  • Session-based checks on selected pages
  • Logout action that invalidates the session

πŸ‘¨β€πŸ’Ό Employee Management

  • Add a new employee
  • Search for an employee by ID
  • View the employee list on management pages
  • Update employee information
  • Remove an employee by ID

πŸ—ƒοΈ Persistence Layer

  • MySQL database integration
  • Hibernate/JPA entity mapping
  • Separate Admin and Employee entities
  • Repository methods for database operations
  • Automatic schema updates configured through Hibernate

🧩 MVC Application Structure

  • Annotation-based controllers
  • @GetMapping and @PostMapping request handlers
  • Service layer for application operations
  • JSP view resolver
  • Reusable navigation and separate feature pages

Project note: The code includes the above features, but authentication and request protection are not yet consistently enforced across every endpoint. See Known Limitations before using the application with real or sensitive data.


πŸ”„ How It Works

The application uses Spring MVC to route requests to controllers, service classes to coordinate operations, repositories to interact with JPA, and Hibernate to persist entities in MySQL.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚       Browser / JSP UI       β”‚
β”‚ Login Β· Signup Β· Employee UI β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚ HTTP Request
               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚        Spring MVC             β”‚
β”‚ AdminController               β”‚
β”‚ EmployeeController            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚        Service Layer          β”‚
β”‚ AdminService                  β”‚
β”‚ EmployeeService               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚       Repository Layer        β”‚
β”‚ AdminRepository               β”‚
β”‚ EmployeeRepository            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚ JPA / Hibernate
               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚          MySQL                β”‚
β”‚ Admin and Employee records    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Typical Employee Workflow

  1. Open the application and go to the signup or login page.
  2. Sign in through the admin login page.
  3. Open the employee section from the navigation bar.
  4. Add a new employee or search for an existing employee by ID.
  5. Update employee details or remove a record as needed.
  6. Review the success or error message returned by the relevant page.

🧱 Application Architecture

The source code is arranged into four main application layers:

Layer Package / Files Responsibility
Controller Controller/ Maps HTTP routes, receives form fields, and selects JSP views
Service Service/ Exposes admin and employee operations to controllers
Repository Repository/ Uses JPA and Hibernate to persist, query, update, and delete records
Entity Entity/ Maps Java classes to database entities
Views WEB-INF/View/ Renders login, signup, home, add, search, update, and remove pages

Spring MVC is configured in dispatcher-servlet.xml, which enables component scanning and annotation-driven request mapping, and resolves view names to JSPs under /WEB-INF/View/.


πŸ› οΈ Technology Stack

Java Spring MVC JSP Hibernate Jakarta Persistence MySQL Maven Eclipse IDE

Category Technology / Current Configuration
Language Java (Eclipse project metadata targets Java 21; Maven compiler properties currently specify source/target 8)
Web Framework Spring Web MVC 7.0.8
View Technology JavaServer Pages (JSP)
Persistence Jakarta Persistence API with Hibernate ORM 6.5.2.Final
Database MySQL
Database Driver MySQL Connector/J 8.4.0
Servlet API Jakarta Servlet API 6.0.0 (provided scope)
Boilerplate Reduction Lombok 1.18.46
Build Tool Apache Maven; WAR packaging
IDE Metadata Eclipse Web Tools / Maven integration

Compatibility note: The checked-in configuration contains a mix of version targets: Maven compiler source/target 8, Eclipse Java facet 21, Spring Framework 7.0.8, and Jakarta Servlet API 6.0.0. This combination should be reviewed and aligned before changing runtimes or relying on a clean deployment. The README documents the repository configuration; it does not claim that every supported runtime combination has been tested.


πŸ“‚ Project Structure

SpringMVC/
β”‚
β”œβ”€β”€ pom.xml
β”œβ”€β”€ .gitignore
β”œβ”€β”€ .classpath
β”œβ”€β”€ .project
β”‚
└── src/
    └── main/
        β”œβ”€β”€ java/
        β”‚   └── com/linkcode/SpringMVC/
        β”‚       β”œβ”€β”€ app.java
        β”‚       β”‚
        β”‚       β”œβ”€β”€ Controller/
        β”‚       β”‚   β”œβ”€β”€ AdminController.java
        β”‚       β”‚   └── EmployeeController.java
        β”‚       β”‚
        β”‚       β”œβ”€β”€ Entity/
        β”‚       β”‚   β”œβ”€β”€ Admin.java
        β”‚       β”‚   └── Employee.java
        β”‚       β”‚
        β”‚       β”œβ”€β”€ Repository/
        β”‚       β”‚   β”œβ”€β”€ AdminRepository.java
        β”‚       β”‚   └── EmployeeRepository.java
        β”‚       β”‚
        β”‚       └── Service/
        β”‚           β”œβ”€β”€ AdminService.java
        β”‚           └── EmployeeService.java
        β”‚
        β”œβ”€β”€ resources/
        β”‚   └── META-INF/
        β”‚       └── persistence.xml
        β”‚
        └── webapp/
            β”œβ”€β”€ index.jsp
            └── WEB-INF/
                β”œβ”€β”€ dispatcher-servlet.xml
                └── View/
                    β”œβ”€β”€ Add.jsp
                    β”œβ”€β”€ Home.jsp
                    β”œβ”€β”€ Login.jsp
                    β”œβ”€β”€ Navbar.jsp
                    β”œβ”€β”€ Remove.jsp
                    β”œβ”€β”€ Search.jsp
                    β”œβ”€β”€ Signup.jsp
                    └── Update.jsp

βš™οΈ Prerequisites

Before running the project, make sure you have:

  • JDK installed and configured in Eclipse
  • Apache Maven (or Eclipse Maven integration)
  • MySQL Server
  • Eclipse IDE for Enterprise Java and Web Developers, or another IDE that supports Maven web applications
  • A servlet container compatible with the project's Jakarta Servlet dependencies

The exact JDK and server combination should be chosen after resolving the compatibility note above.


πŸš€ Installation & Setup

1️⃣ Clone the Repository

git clone https://github.com/TanmayT134/SpringMVC.git
cd SpringMVC

2️⃣ Import the Project into Eclipse

  1. Open Eclipse.
  2. Select File β†’ Import β†’ Maven β†’ Existing Maven Projects.
  3. Choose the cloned SpringMVC folder.
  4. Finish the import and allow Maven to resolve dependencies.
  5. Confirm the installed JDK and project facets match your intended runtime.
  6. Configure a compatible servlet container in the Servers view if you plan to run it from Eclipse.

3️⃣ Configure MySQL

The persistence unit is named springMVC. Its current JDBC URL is:

jdbc:mysql://localhost:3306/springMVC?createDatabaseIfNotExist=true

In src/main/resources/META-INF/persistence.xml, configure the following properties for your local MySQL installation:

<property name="jakarta.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="jakarta.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/springMVC?createDatabaseIfNotExist=true"/>
<property name="jakarta.persistence.jdbc.user" value="YOUR_MYSQL_USERNAME"/>
<property name="jakarta.persistence.jdbc.password" value="YOUR_MYSQL_PASSWORD"/>

Replace the username and password placeholders with your local database credentials. Keep real credentials out of the public repository. The configuration currently sets hibernate.hbm2ddl.auto to update, so Hibernate may update the schema when the application starts.

4️⃣ Build the WAR

From the project root, run:

mvn clean package

The configured Maven build final name is SpringMVC, so the WAR is expected at:

target/SpringMVC.war

If the build fails, first check Maven dependency resolution and the Java/Spring/Servlet compatibility noted above. This command is documented as the project's Maven build path; successful build or deployment has not been verified as part of this README.

5️⃣ Deploy and Run

Deploy target/SpringMVC.war to a servlet container that is compatible with the resolved dependency versions, or configure the application server in Eclipse and run the project on that server.

The local address is typically:

http://localhost:8080/SpringMVC/

The context path may differ depending on the server configuration. The current index.jsp is a simple Hello World page; use the application's /login or /signup routes to open the admin pages.


🧭 Application Routes

The controllers define the following routes:

Method Route Purpose
GET /login Display the admin login page
POST /login Submit admin login credentials
GET /signup Display the admin signup page
POST /signup Create an admin account
GET /logout Invalidate the current session and show login
GET /home Open the home page when the expected session attribute is available
GET / POST /add Display the add form / create an employee
GET / POST /search Display search form / find employee by ID
GET / POST /update Display update page / retrieve employee details by ID
POST /updateemp Save employee changes
GET / POST /remove Display the employee list / remove an employee by ID

Open these routes relative to the deployed application context, for example /SpringMVC/login.


πŸ—ƒοΈ Data Model

Admin

The Admin entity contains:

  • id β€” generated primary key
  • username β€” admin username
  • password β€” currently stored as a plain string by the application

Employee

The Employee entity contains:

  • id β€” generated primary key
  • name β€” employee name
  • email β€” employee email
  • designation β€” employee designation
  • contact β€” contact number
  • salary β€” employee salary

Hibernate is configured to create or update mapped tables using hibernate.hbm2ddl.auto=update; no SQL schema file is currently included in the project tree.


πŸ” Security & Known Limitations

This is a learning project that demonstrates Spring MVC request mapping, layered application code, JSP views, and database persistence. It should not be treated as production-ready authentication software in its current form.

  • Credentials: Configure your own MySQL username/password in persistence.xml. Do not commit real credentials to a public repository.
  • Password storage: The current Admin entity and repository store and compare passwords as plain strings. Use a password-hashing algorithm before using real user accounts.
  • Login query: The login repository currently constructs JPQL by concatenating user input. Replace it with a parameterized query to avoid query-injection risks.
  • Session consistency: The login controller stores the result list under the login session attribute, while some employee controller methods expect a single Admin object. These types should be made consistent and tested.
  • Endpoint checks: Some employee GET routes check for a session attribute, but the POST handlers do not consistently enforce the same access check. Protect all state-changing operations before exposing the application to untrusted users.
  • Session timeout: The current login controller sets a very short session inactive interval. Review it for the intended use case.
  • Persistence resources: Repository classes manage static JPA resource fields. Consider request-safe resource handling and proper cleanup/transaction management as the application evolves.
  • Compatibility: Align Java compiler settings, Spring Framework, Jakarta Servlet API, and the target server before upgrading or deploying.

These notes describe observed source-level limitations and recommended improvements; they are not claims that those improvements have already been implemented.


πŸ›£οΈ Future Enhancements

Potential next steps for the project include:

πŸ” Authentication

  • Hash admin passwords
  • Use parameterized JPQL queries
  • Enforce authentication consistently across all routes
  • Add validation for signup and login fields
  • Review session timeout and logout behavior

πŸ‘¨β€πŸ’Ό Employee Management

  • Add server-side field validation
  • Validate email, contact number, and salary values
  • Add confirmation before deleting a record
  • Improve duplicate and invalid-input handling
  • Add pagination and filtering for large employee lists

πŸ—οΈ Architecture & Quality

  • Use constructor injection instead of field injection
  • Manage EntityManager instances and transactions safely
  • Add automated unit and integration tests
  • Align Java, Spring, Servlet, and Hibernate versions
  • Add database migration scripts
  • Add centralized exception handling and logging

🎨 User Experience

  • Add employee list sorting and filtering
  • Improve responsive layouts and form feedback
  • Add a dashboard with employee statistics
  • Add pagination and clearer empty-state messages

πŸŽ“ Learning Outcomes

This project provides practice with:

  • Spring MVC controllers and request mappings
  • Model-to-view data transfer with ModelMap
  • JSP-based server-rendered pages
  • Dependency injection and service layers
  • Repository-layer database operations
  • JPA entities and Hibernate ORM
  • MySQL connectivity
  • Maven WAR packaging
  • Session attributes and request handling
  • CRUD implementation in a Java web application

🀝 Contributing

Contributions and suggestions are welcome.

  1. Fork the repository.
  2. Create a feature branch.
  3. Make and test your changes locally.
  4. Commit your changes with a descriptive message.
  5. Push your branch and open a Pull Request.

For changes involving authentication, persistence, or dependencies, please include testing steps and note any configuration changes.


πŸ‘¨β€πŸ’» Developer

Tanmay Tawade

GitHub Profile LinkedIn Profile Portfolio


⭐ Support

If you find this project useful for learning Spring MVC and Java web development, consider starring the repository or sharing suggestions for improvement.

Employee Management System
Built with Java, Spring MVC, Hibernate/JPA, JSP, and MySQL.

About

A Java-based Employee Management System built with Spring MVC, JSP, Hibernate/JPA, and MySQL, featuring admin login and employee CRUD operations.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages