Skip to content

A Java Web-Based Online Voting System using Servlets, JSP, JDBC, and MySQL. Supports secure voter login, one-vote-per-user rule, admin management of voters and candidates, and real-time results. Implements MVC structure, DAO pattern, and JDBC transactions for reliable digital voting.

Notifications You must be signed in to change notification settings

manvendra099/Online-Voting-System-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Web-Based Online Voting System (JSP + Servlets + JDBC + MySQL)

A secure and structured online voting system built using Java Servlets, JSP, JDBC, and MySQL, following the MVC architecture. The system allows voters to register, log in, cast their vote once, and view results. Admins can manage candidates, voters, and monitor results.

πŸ“Œ Features πŸ‘€ Voter Module

Register and log in

Secure authentication

One-vote-per-user rule

Cast vote for available candidates

View voting confirmation

πŸ› οΈ Admin Module

Admin login

Add/manage candidates

View list of registered voters

View live election results

πŸ’Ύ Backend

MySQL database

JDBC connection layer (DAO Pattern)

MVC-based architecture

Form validation & Session management

πŸ“ Project Structure OnlineVotingSystem/ β”‚ β”œβ”€β”€ src/ β”‚ β”œβ”€β”€ dao/ # Database access objects β”‚ └── servlets/ # Java Servlets (Admin, Voter, Voting) β”‚ β”œβ”€β”€ WebContent/ β”‚ β”œβ”€β”€ css/ # Style files β”‚ β”œβ”€β”€ WEB-INF/ β”‚ β”‚ β”œβ”€β”€ web.xml # Deployment descriptor β”‚ β”‚ └── lib/ # MySQL JDBC driver β”‚ └── *.jsp # JSP UI pages β”‚ β”œβ”€β”€ sql/ β”‚ └── setup.sql # SQL script to create DB & tables β”‚ └── README.md

βš™οΈ Technology Stack

Java (JDK 8–17 supported)

JSP / Servlets

MySQL (8.x)

JDBC

Tomcat 9 / 10

Eclipse IDE

πŸ“¦ Database Setup

Install MySQL Server

Open MySQL Shell / Command Line:

mysql -u root -p

Run the database setup script:

SOURCE sql/setup.sql;

πŸ”— Configure Database in Project

Open:

src/dao/DBConnection.java

Update:

private static final String URL = "jdbc:mysql://localhost:3306/votingdb?useSSL=false"; private static final String USER = "root"; private static final String PASS = "YOUR_PASSWORD";

πŸ“₯ Add MySQL JDBC Driver

Download:

➑️ mysql-connector-java-8.x.x.jar

Place it inside:

WebContent/WEB-INF/lib/

Or add to Eclipse Build Path.

πŸš€ Run the Project In Eclipse:

File β†’ Import β†’ Existing Project into Workspace

Select the project root folder

Right-click project β†’ Properties β†’ Target Runtime β†’ Add Tomcat

Right-click project β†’ Run As β†’ Run on Server

Project will start at:

http://localhost:8080/OnlineVotingSystem/

πŸ§ͺ Testing the System Voter:

Register a new voter

Login

Cast a vote

Check results

Admin:

Default admin credentials (if included in SQL):

username: admin password: admin123

Admin Functions:

Add candidate

Manage candidates

View voter list

View result dashboard

πŸ“€ Upload/Push to GitHub git init git add . git commit -m "Initial commit - Online Voting System" git remote add origin https://github.com/YOUR_USERNAME/OnlineVotingSystem.git git push -u origin master

Not recommended for real-world election environments.

Password hashing is minimal/basic.

About

A Java Web-Based Online Voting System using Servlets, JSP, JDBC, and MySQL. Supports secure voter login, one-vote-per-user rule, admin management of voters and candidates, and real-time results. Implements MVC structure, DAO pattern, and JDBC transactions for reliable digital voting.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published