Professional Documents
Culture Documents
1
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Chapter 1: INTRODUCTION
Online voting system using Fingerprint is a web application where the user is
recognized by his finger pattern. Since the finger pattern of each human being is
different, the voter can be easily authenticated. The system allow the voter to vote
through fingerprint. Fingerprint is used to uniquely identify the user. The Fingerprint
minutiae features are different for each human being, voter can vote the candidate
only once and the system will not allow the candidate to vote for the second time. The
system will allow admin to add the candidate name and candidate party symbol who
are nominated for the election.
Admin only has the right to add candidate name and symbol who are nominated. The
number of candidate added to the system by the admin will be deleted after the
completion of the election. Admin has to add the date when the election going to end.
Once the user has got the user id and password then the user can login and vote for the
candidate who are nominated. The system will allow the user to vote for only one
candidate. The system will allow the user to vote for one time for a particular election.
Admin can add any number of candidates when the new election will be announced.
Admin and user can view the election result.
Background
In recent years, the use of biometric technologies has become increasingly popular for
authentication and identification purposes. Fingerprint recognition is one such
technology that has gained significant traction due to its accuracy, reliability, and ease
of use. With the aim of providing a secure and efficient voting system, I have
developed an online voting system that uses fingerprint recognition during the online
registration of user.This system leverages JavaServer Pages (JSP) and Servlet
technologies to enable voters to register and cast their votes with ease and
convenience. By eliminating the need for traditional registration methods, such as
filling out forms for providing personal information.
2
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Objectives
- Ensuring the security of the website and the voting process, including
protecting against hacking, fraud, and other forms of manipulation.
- Offering multiple authentication methods to ensure that only eligible voters can
cast their votes.
- Allowing voters to cast their votes at any time, from anywhere, as long as they
have access to the internet.
Purpose
The purpose of the online voting system using fingerprint is to make web based
secured online portal and user- friendly for the all common people without nominal
knowledge about the voting.
3
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
No Redundancy:-
In the proposed system utmost care would be that no information is repeated
anywhere in storage space and consistency in the data stored.
Easy to operate:-
The system should be easy to operate and will have a very friendly user interface so
that the user can feel very easy to work on it.
Cost Managing:-
The system should be such that it can be developed within a short period of time and
fit in the limited budget by replacing all the manual work with the computer based
system.
Scope
- It allows users to create and manage polls, set voting rules and regulations, and
invite voters to participate.
Applicability
The Online Voting System Using Fingerprint is suitable for use in a wide range of
applications, including academic institutions, government organizations, and corporate
entities. It can be used to conduct various types of polls or elections, such as student
council elections, board member elections, and shareholder meetings. The system is
scalable and can handle large volumes of users and data, making it suitable for use in
organizations of any size. Additionally, the system's user-friendly interface makes it
accessible to voters of all ages and technical backgrounds.
4
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
5
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
- JSP files can contain HTML, Java code, and other types of content that are
processed by a web container (such as Apache Tomcat) to generate a response
to a client's request.
2) Servlets:
- A servlet is a Java class that runs on a web server and handles client
requests.
- Servlets are typically used to process and respond to HTTP requests, such
as those sent by a web browser.
- JSTL is a library of custom tags that can be used in JSP files to simplify
the development of dynamic web pages.
- JSTL provides tags for common tasks such as looping over collections,
formatting dates and numbers, and conditionally displaying content.
- The MVC pattern separates an application into three main components: the
model (which represents the data and business logic), the view (which displays
the data to the user), and the controller (which handles user input and updates
the model and view).
6
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
MySQL: -
1) MySQL Connector/J:
2) Apache Derby:
7
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
8
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Problem Definition
In the recent years there are many literature on online voting has been developed.
While online voting has been an active area of research in the recent years, effort to
develop real-world solutions have just begun posing several new challenges. The use
of insecure Internet, well documented cases of incorrect implementations and the
resulting security breaches have been reported in past. These challenges and concerns
have to be resolved in order to create public trust in online voting. Online voting
system will provide the online registration form for the users before voting and
makes the user to cast their vote online. The system is to be developed with high
security by taking fingerprint of each voter and make system more user-friendly.
Requirements Specification
The purpose of the requirements analysis is to identify requirement for the proposed
system. The emphasis is on the discovery of user requirements. Each requirement
must be defined and documented.
Admin should organize Election and give particular date and time for election.
Voter can vote only one time and can vote only one candidate.
9
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Gantt Chart
10
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Pert Chart
11
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Hardware requirements:
- Graphics Card: Video card that supports a minimum display resolution of 720p.
- Fingerprint Scanner
Software Requirements:
- Window 7/8/8.1
12
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
The product is an election conducting tool with a simple GUI in it. This system is
developed using Advance Java and MySQL. This product is stand-alone. It requires a
back-end server which can be done by NetBeans application by connecting MySQL
JDBC Driver. Our system has a server back-end which takes care of authenticating the
users and maintaining necessary details. The user interface at the server end creating
the election on behalf of the users. The user must login with id and password then they
can access the election module where they can cast their vote with such ease and
comfort and their response will be saved and after the result will be displayed.
Voter Register
Voter verification
Authentication of voters
Result will be displayed fast and accurate because all the work is computer-based
13
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Conceptual Models
Event Table
14
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
3.2.6 ER Model
15
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Use-Case Diagram
Register
Login
Add/Update Candidate
Admin
View Candidate
Voter
Add/update Election
Manage Result
Cast Vote
View Result
Logout
16
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Class Diagram
17
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Sequence Diagram
18
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
3
]p
Register Voter
No
Is voter
register?
Yes
Voter login
Username
Register login error password correct?
Yes
Vote candidate
Vote No
successful?
19
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Activity Diagram
Admin:
Voter:
Authentic Admin
Authentic Admin user and password
user and password
Valid
20
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
21
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Basic Modules
1. Administration Module:-
In this module admin have authority to stores the user information, providing
registration and performing the adding, deleting, updating the candidate and election
information. Admin gives the data for voting process in the particular date specified.
2. Registration Module:-
In this module the voters has to do registration for performing the voting process
through online. Once the registration is completed the admin approves the voters for
voting process. So the users can login and vote for the candidate. The user registration
is performed for security purpose.
3. Voting module:-
In this module voters have the provision to view the list of candidate who are
nominating for the election. So they can vote for the candidate through online. The
voting process can be done only once and for limited time.
4. Fingerprint Module:-
In this module the system allow the voter to vote through his fingerprint as the
fingerprint of each human being is different the voter can be easily authenticated the
login will be successful only when the user fingerprint matches to vote their cast.
5. Security Module:-
In this module Auto-logout feature take care of the rest, after a vote has been placed
and the main login screen is restored. So that the duplicate vote can be avoided only
one vote can be created by a single user. So it will be more secure and efficient.
6 .Counting Module:-
In this module counting is performed. The vote acquired by each candidate will be
displayed. Total number of votes for each candidate is calculated and displayed. The
candidate with maximum vote is awarded as winning candidate.
7. Result Module:-
In this module the admin get the final report of the voting. The candidate with higher
vote is displayed as winning candidate. The details regarding the voting process will
be stored in the database for future reference.
22
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Data Design
Foreign Key is a field (or collection of fields) in one table, that refers to the
PRIMARY KEY in another table. The table with the foreign key is called the
child table, and the table with the primary key is called the referenced or parent
table.
Not Null Constraint makes sure that a column is not left null. It forces the
person to enter some value else it will show an error.
4. Unique Constraint:
Unique Constraint the name itself suggests that a column will have a unique
value. This constraint makes sure that columns don’t have any duplicate
values.
5. Auto Increment:
The Constraints applied to whichever column will see that it increments itself
whenever a new record is inserted so that the duplication is not generated.
23
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
1. Admin Table
2. Voter Table
ID Int Auto-Increment
24
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
3. Candidate Table
4. Election table
25
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
5. Votes Table
26
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Admin
Username:varchar(25) Password: Varchar (25)
Candidate
ID:Int
Name: Varchar (25)
Email: Varchar (40) Date: Date
Address: Varchar(50) Contact: Int
File: Blob Gender :Bool
Voter
VoterID:int Name:varhcra(25) Username:varchar(20) Pass:varchar(15) Email:varchar(20) Date:date
Contact:int Address:varchar(40) Photo:Blob Gender:bool Ansi:long text
Election
Ename:Varchar(20) Cid:int Name:varchar(25) Email:varch
Vote:int
Votes
Uname:varchar(40) Ename:varhar(40)
27
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Security Issue
A secure voting system is an end-to-end verifiable voting system that also employs
general computer security principles.
28
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
29
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Implementation approachesI
(Admin)LogIn Page:
Description:
This is admin login page where admin have to give username and password to access
the website. Correct login credentials redirect them to their respective portal, while
incorrect passwords display an error message ('Incorrect Password. Please try again.').
Unique email-ID and password combinations ensure secure access to the voting
system for authorized personnel."
30
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Description:
When Admin will login successfully then home page will open. In this page you can
see various option like :-
Add Candidate: Add a new candidate to the list of candidates for the upcoming
election.
Manage Candidate: Update or delete the details of a candidate that has already been
added.
Add Election: Generate a new election and specify theend dates and the type of
election.
Result Declaration: Announce the final results of the election based on the vote count.
Logout: Log out of the system and end the current session.
31
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Add Candidate
Description:
This feature enables the admin to add a new candidate to the list of candidates for the
upcoming election. The admin can enter the candidate's name, party symbol, and other
relevant details. This makes it easy for the administrator to manage the list of
candidates and ensures that voters have access to up-to-date information on who they
can vote for.
32
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Manage Candidate
Description:
This is Manage Candidate page which allows the admin to update or delete the details
of a candidate that has already been added. The admin can edit the candidate's name,
party affiliation, or any other relevant details. Additionally, the admin can also delete
a candidate from the list if required.
33
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Add Election
Description:
This is Add election page which allows the admin to generate a new election and
specify te end dates for the election. The admin can also specify the type of election
such as presidential or parliamentary and add as many candidates as required.Admin
can also delete the candidate name from election list.
34
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Result
Description:-
This is Result Page in which admin can view the winner of particular election by
selecting election topic or name in select tag and click on view result .After that
admin can view the list of candidate who was register for specified election ,It show
candidate id,name and number of vote he/she got.
35
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
(User)Login Page
Description:-
This page includes a user login page with a forget password feature and a registration
link. Users can securely log in using their unique username and password, and in case
they forget their password, they can easily reset it using the forget password feature.
Additionally, new users can register themselves through the registration link to gain
access to the voting system.
36
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Register Page
Description:-
The registration page allows new users to sign up and create their account. It includes
fields for entering personal information such as name, email address, photo,fingerprint
and a unique username and password for secure login. After filling out the required
details and submitting the registration form, users can access the voting system and
participate in the voting process.
37
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Description:
This page is user home page which have many option like:
View Candidate:-User can view the candidate who is standing for particular election
Result:-In this page user can view the election result after the election is completed
View Profile:In this page user can view their profile and can also update the profile
AboutUs:-This page allow the user to give information of about the website and give
feedback or any query throught gmail.
38
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
View Candidate :
Description:
In this page user can view the candidate for particular election and give vote user can
give vote only one time for particular election .If he/she has given vote in particular
election then he/she cannot view the candidate.
39
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Result Page:-
Description:
In Result Page user can view the result of particular election result will only declared
after the end date or completion of election.
40
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
About Us
Description:-
This is Aboutus page where user can give feedback or he/she have any query related
to website.This page give information about the website.
41
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Admin.jsp
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>Online Voting System</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel='stylesheet'
href='newcss.css'
type='text/css'
media='all'>
<script src="https://kit.fontawesome.com/a076d05399.js"
crossorigin="anonymous"></script>
</head>
<body>
<header class="site-header">
<div class="site-identity">
<a href="#"><img src="images/logo.png" alt="Site Name" width="140px"
height="70px"/></a>
<h1 style="color:white;"><a href="#">Online Voting System</a></h1>
</div>
<nav class="site-navigation">
<ul class="nav">
<li><a href="index.html">Admin</a></li>
<li><a href="userlogin.jsp">Voter</a></li>
</ul>
</nav>
42
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
</header>
<br><br><br><br><br><br>
<center>
<div class="wrapper">
<div class="title"><span>ADMIN LOGIN PANEL</span></div>
<form action="login" method="post">
<div class="row">
<i class="fas fa-user"></i>
<input type="text" placeholder="Username" name="textid" required>
</div>
<div class="row">
<i class="fas fa-lock"></i>
<input type="Password" placeholder="Password" name="pwd" required>
</div>
<div class="row button">
<input type="submit" value="Login">
</div>
</form>
</div>
</body>
</html>
Login.java
package mypack;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@Override
43
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
44
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Login Page
Component Table
Logincheck.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mypack;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
*
* @author khadk
*/
public class logincheck extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out=response.getWriter();
String uname=request.getParameter("textid");
String upass=request.getParameter("pwd");
45
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
if(LoginDao.validate(uname, upass)){
HttpSession hs=request.getSession();
hs.setAttribute("uname",uname);
RequestDispatcher rd=request.getRequestDispatcher("userhome.jsp");
rd.forward(request,response);
}
else{
out.println("<script type=\"text/javascript\">");
out.println("alert('User or password incorrect');");
out.println("</script>");
RequestDispatcher rd=request.getRequestDispatcher("userlogin.jsp");
rd.include(request,response);
}
out.close();
}
}
LoginDao.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mypack;
import java.sql.*;
public class LoginDao {
public static boolean validate(String name,String pass){
boolean status=false;
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con
=DriverManager.getConnection("jdbc:derby://localhost:1527/VOTING","VOTING","
VOTING");
PreparedStatement ps=con.prepareStatement( "select * from REGISTER
where UNAME=? and PASS=?");
ps.setString(1,name);
ps.setString(2,pass);
ResultSet rs=ps.executeQuery();
status=rs.next();
}catch(Exception e){System.out.println(e);}
return status;
} }
46
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
(User)Register Page
Component Table
Registerstore.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mypack;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.http.HttpServlet;
47
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
/**
*
* @author khadk
*/
@MultipartConfig(maxFileSize=16177216)
public class registerstore extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String voter=request.getParameter("txtvoter");
String fname=request.getParameter("txtname");
String id=request.getParameter("txtid");
String email=request.getParameter("txtemail");
String pass=request.getParameter("txtpass");
String dob=request.getParameter("txtdob");
String aadr=request.getParameter("txtaddr");
String cont=request.getParameter("txtcon");
Part part=request.getPart("txtfile");
String gend=request.getParameter("gender");
String AnsiTemplate=request.getParameter("Base64EncodedANSI");
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con
=DriverManager.getConnection("jdbc:derby://localhost:1527/VOTING","VOTING","
VOTING");
PreparedStatement pst=con.prepareStatement("insert into REGISTER
values(DEFAULT,?,?,?,?,?,?,?,?,?,?,?)");
InputStream is=part.getInputStream();
pst.setString(1,voter);
pst.setString(2,fname);
pst.setString(3,id);
pst.setString(4,email);
pst.setString(5,pass);
48
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
pst.setString(6,dob);
pst.setString(7,aadr);
pst.setString(8,cont);
pst.setBlob(9,is);
pst.setString(10,gend);
pst.setString(11,AnsiTemplate);
int i=pst.executeUpdate();
if(i>0)
out.println("<script type=\"text/javascript\">");
out.println("alert('You are successfully registered...');");
out.println("</script>");
RequestDispatcher rd=request.getRequestDispatcher("register.jsp");
rd.include(request, response);
}
catch(Exception e)
{
out.println(e);
}
49
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
AdminNavigation Page
Component Table
Adminhead.jsp
<%--
Document : Home
Created on : 19 Jan, 2023, 2:40:26 PM
Author : khadk
--%>
50
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
<div class="nav-header">
</div>
</header>
<div class="navbar">
<ul>
<li><a href="Home.jsp">Home</a></li>
<li><a href="candidateregister.jsp">Add Candidate</a></li>
<li><a href="display.jsp">Manage Candidate</a></li>
<li><a href="AddElection.jsp">Add Election</a></li>
<li><a href="adminresult.jsp">Result</a></li>
<li><a href="logout.jsp">Logout</a></li>
</ul>
</div>
51
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Code:-
Home.jsp:-
<%--
Document : Home
Created on : 19 Jan, 2023, 2:40:26 PM
Author : khadk
--%>
</div>
</header>
<div class="navbar">
<ul>
<li><a href="Home.jsp">Home</a></li>
<li><a href="candidateregister.jsp">Add Candidate</a></li>
<li><a href="display.jsp">Manage Candidate</a></li>
52
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
<div class="container">
<img src="images/Election_Header.jpg" alt="Site Name" width="1515px"
height="600px"/>
<button class="btn">Get Started</button>
<div class="top-left">Online <br> VOTE</div>
<div class="top-middle">User can give his\her vote online <br> with out going to
any polling booth.</div>
<div class="hompage"><h2>Why Choose Us?</h2></div><div class="hompage-
cont"><span>This website is the best eVoting software due to following
reasons</span></div>
<br><div class="row">
<div class="column">
<img class="" src="https://dymk4s89vutua.cloudfront.net/wp-
content/plugins/r2v-api/images/icons/secured.png?x41032" width="50px"
height="50px" alt="100% Secure">
<h3>100% Secure</h3>
<p>
Right2Vote's online voting system has many layers of security
making the platform <span>100% secure.</span>
Security features include encryption, authentication based on Biometric.
</p>
</div>
<div class="column">
<img class="" src="https://dymk4s89vutua.cloudfront.net/wp-
content/plugins/r2v-api/images/icons/secured.png?x41032" width="50px"
height="50px" alt="100% Secure">
<h3>100% Secure</h3>
<p>
Right2Vote's online voting system has many layers of security
making the platform <span>100% secure.</span>
Security features include encryption, authentication based on Biometric.
</p>
</div>
<div class="column">
<img class="" src="https://dymk4s89vutua.cloudfront.net/wp-
content/plugins/r2v-api/images/icons/secured.png?x41032" width="50px"
height="50px" alt="100% Secure">
<h3>100% Secure</h3>
<p>
53
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
54
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Add Candidate
Component Table
Candidatestore.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mypack;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
55
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
import javax.servlet.http.Part;
/**
*
* @author khadk
*/
@WebServlet(name="candidatestore" ,urlPatterns={"/candidatestore"})
@MultipartConfig(maxFileSize=16177216)
public class candidatestore extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
Part part=request.getPart("txtfile");
String fname=request.getParameter("txtname");
String email=request.getParameter("txtemail");
String dob=request.getParameter("txtdob");
String aadr=request.getParameter("txtaddr");
String cont=request.getParameter("txtcon");
String gend=request.getParameter("gender");
if(part!=null) {
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con
=DriverManager.getConnection("jdbc:derby://localhost:1527/VOTING","VOTING","
VOTING");
PreparedStatement pst=con.prepareStatement("insert into CANDIDATE
values(DEFAULT,?,?,?,?,?,?,?)");
InputStream is=part.getInputStream();
pst.setString(1,fname);
pst.setString(2,email);
pst.setString(3,dob);
pst.setString(4,aadr);
pst.setString(5,cont);
pst.setBlob(6,is);
pst.setString(7,gend);
int i=pst.executeUpdate();
if(i>0)
out.println("<script type=\"text/javascript\">");
out.println("alert('You are successfully registered...');");
out.println("</script>");
56
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
RequestDispatcher rd=request.getRequestDispatcher("candidateregister.jsp");
rd.include(request, response);
pst.close();
con.close();
}
catch(Exception e)
{
out.println(e);
}
}
}
}
57
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
DbConnection.java
package com.pst.ir.util;
import java.sql.Connection;
import java.sql.DriverManager;
ImageDto.java
package com.pst.ir.dto;
59
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
ImageDao.java
package com.pst.ir.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import com.pst.ir.dto.ImageDto;
import com.pst.ir.util.DbConnection;
e.printStackTrace();
}
finally{
try{
rs.close();
ps.close();
}
catch(Exception e){
60
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
e.printStackTrace();
}
}
return imageList;
}
e.printStackTrace();
}
}
return image;
}
}
ImageDownloader.java
package
com.pst.ir.downloader; import
java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
61
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
import javax.servlet.annotation.WebServlet;
62
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.pst.ir.dao.ImageDao;
@WebServlet("/ImageDownloader")
public class ImageDownloader extends HttpServlet {
private static final long serialVersionUID = 1L;
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException {
ImageDao dao = null;
ServletOutputStream outputStream = null;
String id = req.getParameter("id");
dao = new ImageDao();
byte[] image = dao.getImage(id);
outputStream = resp.getOutputStream();
outputStream.write(image);
outputStream.close();
}
}
ImageViewerController.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.pst.ir.controller;
import java.io.IOException;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.pst.ir.dao.ImageDao;
import com.pst.ir.dto.ImageDto;
63
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
@WebServlet("/ImageViewerController")
public class ImageViewerController extends HttpServlet {
private static final long serialVersionUID = 1L;
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
ImageDao imageDao = null;
imageDao = new ImageDao();
List<ImageDto> list = imageDao.getData();
req.setAttribute("list", list);
RequestDispatcher dispatcher = req.getRequestDispatcher("image.jsp");
dispatcher.forward(req, resp);
}
}
Image.jsp
<%@page import="java.util.ArrayList"%>
<%@page import="com.pst.ir.dto.ImageDto"%>
<%@page import="java.util.List"%>
<%@ page import="java.sql.*" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Image</title>
<style>
#candidate th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #0047AB;
color: white;
}
#candidate {
font-family: Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
64
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
</style>
</head>
<body>
<center>
<%
List<ImageDto> list = (ArrayList<ImageDto>)request.getAttribute("list");
%>
</table>
</center>
</body>
</html>
65
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Add Election
Component Table
Electionstore.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mypack;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
/**
*
* @author khadk
*/
@WebServlet(name="electionstore" ,urlPatterns={"/electionstore"})
@MultipartConfig(maxFileSize=16177216)
66
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
int cid=Integer.parseInt(request.getParameter("cid"));
String ename=request.getParameter("ename");
String name=request.getParameter("name");
String edate=request.getParameter("edate");
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con
=DriverManager.getConnection("jdbc:derby://localhost:1527/VOTING","VOTING","
VOTING");
PreparedStatement stmt = con.prepareStatement("SELECT * FROM candidate
WHERE NID=?");
stmt.setInt(1, cid);
ResultSet rs = stmt.executeQuery();
// Retrieve the candidate's ID and other details from the candidate table
if (rs.next()) {
String email=rs.getString("EMAIL");
String date = rs.getString("DATE");
byte[] photoBytes = rs.getBytes("File");
String gend=rs.getString("GENDER") ;
stmt2.setString(1, ename);
stmt2.setInt(2,cid);
stmt2.setString(3, name);
stmt2.setString(4,email);
stmt2.setString(5, date);
stmt2.setBytes(6, photoBytes);
stmt2.setString(7, gend);
stmt2.setString(8, edate);
67
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
} out.println("<script type=\"text/javascript\">");
out.println("alert('Successfully Generated...');");
out.println("</script>");
RequestDispatcher rd=request.getRequestDispatcher("AddElection.jsp");
rd.include(request, response);
con.close();
}
catch(Exception e)
{
out.println(e);
}
}
}
68
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Code:
AdminResult.jsp:
<%--
Document : adminresult
Created on : 7 Apr, 2023, 11:00:09 AM
Author : khadk
--%>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Base64"%>
<%@page import="javax.imageio.ImageIO"%>
<%@page import="java.awt.image.BufferedImage"%>
<%@page import="java.io.ByteArrayInputStream"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.Date" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<style>
.cards{
width:20%;
border-radius:5px;
margin:40px;
box-shadow:2px 2px 10px black;
}
.image img{
width:100%;
border-top-right-radius5px;
border-top-left-radius:5px;
}
.title{
text-align: center;
padding:0x;
font-weight: 600;
69
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
font-family:Helvetica, sans-serif ;
}
.container {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
text-align: center;
}
.form {
display: flex;
justify-content: center;
align-items: center;
}
.select {
margin-right: 10px;
}
button {
margin-right: 10px;
margin-top: 1px;
margin-left: 5px;
}
.elec {
font-size: 20px;
color: #0437F2;
font-family: Helvetica, sans-serif;
font-weight: 500;
}
select {
color: black;
font-size: inherit;
padding: .5em;
padding-right: 2.5em;
border: 0;
margin: 0;
border:1px solid black;
width:70%;
border-radius: 3px;
text-indent: 0.01px;
text-overflow: '';
-webkit-appearance: button; /* hide default arrow in chrome OSX */
70
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
input[type=submit]{
width:150px;
margin-top:0px;
padding:8px;
font-size:17px;
color:#fff;
border:none;
font-family:Helvetica, sans-serif;
border-radius:5px;
background-color:#0437F2;
}
#popUpYes:hover {
background-color: orange;
}
form {
display: flex;
align-items: center;
}
select {
flex: 1;
}
input[type="submit"]
{ margin-left: 10px;
}
#candidate th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #0047AB;
color: white;
}
#candidate {
font-family: Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
71
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
padding: 8px;
}
</style>
</head>
<body>
<%@ include file="adminhead.jsp" %>
<br><br>
<%
// Connect to the database
Class.forName("com.mysql.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:derby://localhost:1527/VOTING","VOTING","
VOTING");
// If a topic was selected, query the database for the candidates in that election
Map<Integer, String[]> candidateDetails = new HashMap<Integer, String[]>();
Date endDate = null; // Initialize endDate to null
if (selectedTopic != null && !selectedTopic.isEmpty()) {
PreparedStatement stmt2 = conn.prepareStatement("SELECT cid, name, vote, edate
FROM election WHERE ename = ?");
stmt2.setString(1, selectedTopic);
ResultSet rs2 = stmt2.executeQuery();
// Build a map of candidate IDs to candidate details (name and vote count)
while (rs2.next()) {
int cid = rs2.getInt("cid");
String candidateName = rs2.getString("name");
int voteCount = rs2.getInt("vote");
Date electionEndDate = rs2.getDate("edate"); // Fetch the end date from the
database
72
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
%>
<div class="container">
<center><div class="elec">Select an election topic:-</div></center>
<form action="" method="get">
<label for="electionTopic"></label>
<select name="electionTopic" id="electionTopic">
<option value="">--Select a topic--</option>
<% for (String topic : electionTopics) { %>
<option value="<%= topic %>"><%= topic %></option>
<% } %>
</select>
<input type="submit" id="popUpYes" value="View Result">
</form>
</div>
73
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
</table>
</center>
<% } else { %>
<p>No winner has been determined for the <%= selectedTopic %> election.</p>
<% } %>
<%
rs.close();
stmt.close();
conn.close();
%>
74
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
UserNavigation Page
Component Table
USerhead.jsp
<%--
Document : userhead
Created on : 29 Mar, 2023, 11:08:05 AM
Author : khadk
--%>
75
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
</div>
<div class="nav-header">
</div>
</header>
<div class="navbar">
<ul>
<li><a href="userhome.jsp">Home</a></li>
<li><a href="voter.jsp">View Candidate</a></li>
<li><a href="result.jsp">Result</a></li>
<li><a href="viewprofile.jsp">View Profile</a></li>
<li><a href="userlogout.jsp">Logout</a></li>
<li><a href="logout.jsp">About Us</a></li>
</ul>
</div>
</body>
</html>
76
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Code:-
Voter(View Candidate).jsp:-
<%--
Document : voter
Created on : 29 Mar, 2023, 5:16:02 PM
Author : khadk
--%>
<style>
.elec{
font-size:20px;
color:#0437F2;
font-family:Helvetica, sans-serif;
font-weight:500;
}
select {
color: black;
font-size: inherit;
padding: .5em;
padding-right: 2.5em;
border: 0;
margin: 0;
border:1px solid black;
width:15%;
border-radius: 3px;
text-indent: 0.01px;
text-overflow: '';
-webkit-appearance: button; /* hide default arrow in chrome OSX */
}
input[type=submit]{
width:150px;
margin-top:0px;
padding:8px;
font-size:17px;
77
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
color:#fff;
border:none;
font-family:Helvetica, sans-serif;
border-radius:5px;
background-color:#0437F2;
}
#popUpYes:hover {
background-color: orange;
}
.cards{
width:20%;
display:inline-block;
border-radius:5px;
margin:40px;
box-shadow:2px 2px 10px black;
}
.image img{
width:100%;
border-top-right-radius5px;
border-top-left-radius:5px;
}
.title{
text-align: center;
padding:0x;
}
.des{
text-align:center;
padding:4px;
}
button{
margin-top:30px;
margin-bottom:30px;
background-color:white;
border:1px solid black;
padding:5px;
border-radius:5px;
cursor:pointer;
}
button:hover{
background-color:#0437F2;
color:white;
transition:.5s
78
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
}
.container {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
text-align: center;
}
.form {
display: flex;
justify-content: center;
align-items: center;
}
.select {
margin-right: 10px;
}
.elec {
margin-right: 10px;
}
button {
margin-right:10px;
margin-top: 1px;
margin-left: 5px;
}
</style>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%@ include file="userhead.jsp" %>
<br><br><br>
<%
79
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
if (selectedTopic != null) {
// Check if the user has already voted for this topic
PreparedStatement ps = conn.prepareStatement("SELECT * FROM votes WHERE
USERNAME=? AND ENAME=?" );
ps.setString(1, username);
ps.setString(2, selectedTopic);
if (rs1.next()) {
// User has already voted, display an error message
out.println("<script type=\"text/javascript\">");
out.println("alert('You have already voted .');");
80
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
out.println("</script>");
} else {
// User has not voted yet, display the candidate information and a vote button
rs = stmt.executeQuery("SELECT cid,name, file, gender FROM election
WHERE ename='" + selectedTopic + "'");
while (rs.next()) {
int cid=rs.getInt("cid");
String cname = rs.getString("name");
Blob cphoto = rs.getBlob("file");
String cgender = rs.getString("gender");
byte[] cphotoBytes = cphoto.getBytes(1, (int) cphoto.length());
String cphotoBase64 = Base64.getEncoder().encodeToString(cphotoBytes);
81
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Code:-
Result.jsp:-
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Base64"%>
<%@page import="javax.imageio.ImageIO"%>
<%@page import="java.awt.image.BufferedImage"%>
<%@page import="java.io.ByteArrayInputStream"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.Date" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<html>
<head>
<style>
.cards{
width:20%;
border-radius:5px;
margin:40px;
box-shadow:2px 2px 10px black;
}
.image img{
width:100%;
border-top-right-radius5px;
border-top-left-radius:5px;
}
.title{
text-align: center;
padding:0x;
font-weight: 600;
font-family:Helvetica, sans-serif ;
}
.container {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
text-align: center;
}
.form {
82
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
display: flex;
justify-content: center;
align-items: center;
}
.select {
margin-right: 10px;
}
button {
margin-right: 10px;
margin-top: 1px;
margin-left: 5px;
}
.elec {
font-size: 20px;
color: #0437F2;
font-family: Helvetica, sans-serif;
font-weight: 500;
}
select {
color: black;
font-size: inherit;
padding: .5em;
padding-right: 2.5em;
border: 0;
margin: 0;
border:1px solid black;
width:70%;
border-radius: 3px;
text-indent: 0.01px;
text-overflow: '';
-webkit-appearance: button; /* hide default arrow in chrome OSX */
}
input[type=submit]{
width:150px;
margin-top:0px;
padding:8px;
font-size:17px;
color:#fff;
border:none;
font-family:Helvetica, sans-serif;
83
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
border-radius:5px;
background-color:#0437F2;
}
#popUpYes:hover {
background-color: orange;
}
form {
display: flex;
align-items: center;
}
select {
flex: 1;
}
input[type="submit"]
{ margin-left: 10px;
}
</style>
</head>
<%@ include file="userhead.jsp" %>
<br><br>
<%
// Connect to the database
Class.forName("com.mysql.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:derby://localhost:1527/VOTING","VOTING","
VOTING");
84
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
// If a topic was selected, query the database for the candidates in that election
String winnerName = "";
String winnergender="";
int winnerVoteCount = 0;
byte[] winnerPhoto = null;
Date endDate = null; // Initialize endDate to null
if (selectedTopic != null && !selectedTopic.isEmpty()) {
PreparedStatement stmt2 = conn.prepareStatement("SELECT name,gender, file,
vote, edate FROM election WHERE ename = ?");
stmt2.setString(1, selectedTopic);
ResultSet rs2 = stmt2.executeQuery();
// Calculate the total votes for each candidate and determine the winner
int maxVotes = 0;
while (rs2.next()) {
String candidateName = rs2.getString("name");
String candidategender=rs2.getString("gender");
byte[] candidatePhoto = rs2.getBytes("file");
int voteCount = rs2.getInt("vote");
Date electionEndDate = rs2.getDate("edate"); // Fetch the end date from the
database
if (voteCount > maxVotes) {
maxVotes = voteCount;
winnerName = candidateName;
winnerPhoto = candidatePhoto;
winnergender= candidategender;
winnerVoteCount = voteCount;
}
if (endDate == null || electionEndDate.after(endDate)) {
endDate = electionEndDate;
}
}
}
%>
<div class="container">
<center><div class="elec">Select an election topic:</div></center>
<form action="" method="get">
<label for="electionTopic"></label>
<select name="electionTopic" id="electionTopic">
<option value="">--Select a topic--</option>
<% for (String topic : electionTopics) { %>
<option value="<%= topic %>"><%= topic %></option>
<% } %>
</select>
<input type="submit" id="popUpYes" value="View Result">
85
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
</form>
</div>
</html>
<% if (endDate == null) { %>
<p>No winner has been determined for the <%= selectedTopic %> election.</p>
<% } %>
<%
rs.close();
stmt.close();
conn.close();
%>
86
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Code:-
Aboutus.jsp:-
<%--
Document : Aboutus
Created on : 14 Apr, 2023, 6:12:46 AM
Author : khadk
--%>
<!DOCTYPE html>
<html>
<head>
<title>About Us</title>
</head>
<body>
<h2>Our Team</h2>
<ul>
<li>Maanbahadur khadka -Web Desinger</li>
</ul>
<h2>Contact Us</h2>
<p>If you have any questions or feedback about our system, please feel free
to contact us:</p>
<ul>
<li>Email: khadkamaanbahadur15@gmail.com</li>
<li>Phone: 555-1234</li>
<li>Address: 123 Main St, Anytown USA</li>
</ul>
87
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Acceptance Testing
System Testing
Integration Testing
Unit Testing
88
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Acceptance Testing
System Testing
Integration Testing
Unit Testing
89
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
BETA TESTING :
90
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Sr. Form Name Test Case Test Data State Test Input Exp.
No Value Result
1 Admin Username Alphabetic Valid Admin12 Allowed
Login and Number to enter
data
Null Invalid Error
Message
Password Alphabetic, Valid Abc@1234 Allowed
Number, to enter
Symbol data
Null Invalid Error
Message
2 Voter VoterId Alphabetic valid Maan12 Allowed
Register and to enter
Number data
Number Invalid 12345 Error
Message
Special Invalid !@#$%^&*()- Error
Symbol +?;:”’~ Message
Name Alphabetic valid Maan Allow
to enter
data
Number invalid 4151 Error
Message
Special !@#$%^&*()- Error
Symbol +?;:”’~ Message
Username Alphabetic Valid Maan12 Allowed
and Number to enter
data
Null Invalid Error
Message
Password Alphabetic, Valid Abc@1234 Allowed
Number, to enter
Symbol data
Null Invalid Error
Message
91
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
92
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
93
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
94
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
95
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
Test
Report
1)Admin
:- Result
Code:-
Adminresult.jsp
<%--
Document : adminresult
Created on : 7 Apr, 2023, 11:00:09 AM
Author : khadk
--%>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Base64"%>
<%@page import="javax.imageio.ImageIO"%>
<%@page import="java.awt.image.BufferedImage"%>
<%@page import="java.io.ByteArrayInputStream"%>
96
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
97
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<style>
.cards{
width:20%;
border-radius:5px;
margin:40px;
box-shadow:2px 2px 10px black;
}
.image img{
width:100%;
border-top-right-radius5px;
border-top-left-radius:5px;
}
.title{
text-align: center;
padding:0x;
font-weight: 600;
font-family:Helvetica, sans-serif ;
}
.container {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
text-align: center;
}
.form {
display: flex;
justify-content: center;
align-items: center;
}
.select {
margin-right: 10px;
}
98
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
button {
margin-right: 10px;
margin-top: 1px;
margin-left: 5px;
}
.elec {
font-size: 20px;
color: #0437F2;
font-family: Helvetica, sans-serif;
font-weight: 500;
}
select {
color: black;
font-size: inherit;
padding: .5em;
padding-right: 2.5em;
border: 0;
margin: 0;
border:1px solid black;
width:70%;
border-radius: 3px;
text-indent: 0.01px;
text-overflow: '';
-webkit-appearance: button; /* hide default arrow in chrome OSX */
}
input[type=submit]{
width:150px;
margin-top:0px;
padding:8px;
font-size:17px;
color:#fff;
border:none;
font-family:Helvetica, sans-serif;
border-radius:5px;
background-color:#0437F2;
}
#popUpYes:hover {
background-color: orange;
}
99
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
form {
display: flex;
align-items: center;
}
select {
flex: 1;
}
input[type="submit"]
{ margin-left: 10px;
}
#candidate th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #0047AB;
color: white;
}
#candidate {
font-family: Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
</style>
</head>
<body>
<%@ include file="adminhead.jsp" %>
<br><br>
<%
// Connect to the database
Class.forName("com.mysql.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:derby://localhost:1527/VOTING","VOTING","
VOTING");
100
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
// If a topic was selected, query the database for the candidates in that election
Map<Integer, String[]> candidateDetails = new HashMap<Integer, String[]>();
Date endDate = null; // Initialize endDate to null
if (selectedTopic != null && !selectedTopic.isEmpty()) {
PreparedStatement stmt2 = conn.prepareStatement("SELECT cid, name, vote, edate
FROM election WHERE ename = ?");
stmt2.setString(1, selectedTopic);
ResultSet rs2 = stmt2.executeQuery();
// Build a map of candidate IDs to candidate details (name and vote count)
while (rs2.next()) {
int cid = rs2.getInt("cid");
String candidateName = rs2.getString("name");
int voteCount = rs2.getInt("vote");
Date electionEndDate = rs2.getDate("edate"); // Fetch the end date from the
database
candidateDetails.put(cid, new String[] {candidateName,
Integer.toString(voteCount)});
if (endDate == null || electionEndDate.after(endDate)) {
endDate = electionEndDate;
}
}
}
%>
<div class="container">
<center><div class="elec">Select an election topic:-</div></center>
<form action="" method="get">
<label for="electionTopic"></label>
<select name="electionTopic" id="electionTopic">
<option value="">--Select a topic--</option>
<% for (String topic : electionTopics) { %>
<option value="<%= topic %>"><%= topic %></option>
<% } %>
101
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
</select>
<input type="submit" id="popUpYes" value="View Result">
</form>
</div>
<%
rs.close();
stmt.close();
conn.close();
%>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<%@ include file="footer.jsp" %>
</body>
</html>
102
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
2) User :-
Result
-
Code:-
Result.jsp
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Base64"%>
<%@page import="javax.imageio.ImageIO"%>
<%@page import="java.awt.image.BufferedImage"%>
<%@page import="java.io.ByteArrayInputStream"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.Date" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<html>
<head>
<style>
.cards{
width:20%;
103
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
border-radius:5px;
margin:40px;
box-shadow:2px 2px 10px black;
}
.image img{
width:100%;
border-top-right-radius5px;
border-top-left-radius:5px;
}
.title{
text-align: center;
padding:0x;
font-weight: 600;
font-family:Helvetica, sans-serif ;
}
.container {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
text-align: center;
}
.form {
display: flex;
justify-content: center;
align-items: center;
}
.select {
margin-right: 10px;
}
button {
margin-right: 10px;
margin-top: 1px;
margin-left: 5px;
}
.elec {
font-size: 20px;
color: #0437F2;
font-family: Helvetica, sans-serif;
font-weight: 500;
104
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
select {
color: black;
font-size: inherit;
padding: .5em;
padding-right: 2.5em;
border: 0;
margin: 0;
border:1px solid black;
width:70%;
border-radius: 3px;
text-indent: 0.01px;
text-overflow: '';
-webkit-appearance: button; /* hide default arrow in chrome OSX */
}
input[type=submit]{
width:150px;
margin-top:0px;
padding:8px;
font-size:17px;
color:#fff;
border:none;
font-family:Helvetica, sans-serif;
border-radius:5px;
background-color:#0437F2;
}
#popUpYes:hover {
background-color: orange;
}
form {
display: flex;
align-items: center;
}
select {
flex: 1;
}
input[type="submit"]
{ margin-left: 10px;
}
105
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
</style>
</head>
<%@ include file="userhead.jsp" %>
<br><br>
<%
// Connect to the database
Class.forName("com.mysql.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:derby://localhost:1527/VOTING","VOTING","
VOTING");
// If a topic was selected, query the database for the candidates in that election
String winnerName = "";
String winnergender="";
int winnerVoteCount = 0;
byte[] winnerPhoto = null;
Date endDate = null; // Initialize endDate to null
if (selectedTopic != null && !selectedTopic.isEmpty()) {
PreparedStatement stmt2 = conn.prepareStatement("SELECT name,gender, file,
vote, edate FROM election WHERE ename = ?");
stmt2.setString(1, selectedTopic);
ResultSet rs2 = stmt2.executeQuery();
// Calculate the total votes for each candidate and determine the winner
int maxVotes = 0;
while (rs2.next()) {
String candidateName = rs2.getString("name");
String candidategender=rs2.getString("gender");
byte[] candidatePhoto = rs2.getBytes("file");
int voteCount = rs2.getInt("vote");
Date electionEndDate = rs2.getDate("edate"); // Fetch the end date from the
106
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
database
if (voteCount > maxVotes) {
maxVotes = voteCount;
winnerName = candidateName;
winnerPhoto = candidatePhoto;
winnergender= candidategender;
winnerVoteCount = voteCount;
}
if (endDate == null || electionEndDate.after(endDate)) {
endDate = electionEndDate;
}
}
}
%>
<div class="container">
<center><div class="elec">Select an election topic:</div></center>
<form action="" method="get">
<label for="electionTopic"></label>
<select name="electionTopic" id="electionTopic">
<option value="">--Select a topic--</option>
<% for (String topic : electionTopics) { %>
<option value="<%= topic %>"><%= topic %></option>
<% } %>
</select>
<input type="submit" id="popUpYes" value="View Result">
</form>
</div>
</html>
<% if (endDate == null) { %>
107
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
<p>No winner has been determined for the <%= selectedTopic %> election.</p>
<% } %>
<%
rs.close();
stmt.close();
conn.close();
%>
108
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
User Documentation
1. Click on the Admin that will appear in the right side of the navigation bar.
2. After clicking it Admin login page will appear .
3. Fill the login Page
4. Click on Login Button
5. You will be Successfully Logged in.
109
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
2. After clicking it will automatically redirect the admin to login page after 3
seconds.
1. Click on the Voter link that will be in right side of navigation bar
2. After clicking it login form will open in login form one hyperlink will present
name as Click to “Register Here!” click on that.
3. After Clicking it register form will appear
4. Fill the details.
5. Click on register button
6. Success Register Alert box will appear now are register
successfully.
1. After voter login one home page will appear in that navigation bar
result link will appear click on that.
110
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
2. After clicking the result link page will appear select the election topic from
which election you wan to see result and then click on the result button
3. After clicking it result will be appear in form of candidate name
and photo who have won the particular election.
111
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
112
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
CHAPTER 7 : CONCLUSIONS
Conclusion
An online voting system can provide a convenient and efficient way for people to cast
their votes from the comfort of their homes or workplaces, without the need to
physically go to a polling station. However, there are also several considerations and
potential drawbacks that should be taken into account.
One advantage of an online voting system is that it can increase voter participation, as
it eliminates barriers such as physical distance or mobility issues. It can also reduce
the costs and resources associated with traditional polling stations and paper-based
ballots. Additionally, an online voting system can provide a more efficient and
accurate vote counting process, with results available in real-time.
However, there are also concerns related to the security and integrity of an online
voting system. Hackers and other malicious actors may attempt to interfere with the
system, potentially compromising the confidentiality and accuracy of the votes.
Ensuring the security of the system and protecting against cyber attacks is therefore
crucial.
Another concern is the potential for technical issues or glitches, which could prevent
voters from accessing or using the system, or cause errors in vote counting. This could
undermine confidence in the system and lead to disputes or challenges to the results.
In conclusion, an online voting system has the potential to provide a convenient and
efficient way for people to cast their votes, but it is important to carefully consider and
address the security and technical challenges associated with such a system in order to
ensure its accuracy and legitimacy.
113
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
The significance of an online voting system lies in its potential to improve the
democratic process by making it more accessible, efficient, and accurate. By enabling
voters to cast their ballots from anywhere with an internet connection, an online
voting system can increase voter participation and reduce barriers to access for
individuals who may face physical or logistical challenges in getting to a physical
polling station.
Furthermore, an online voting system can also help reduce the costs and resources
associated with traditional polling stations, such as printing and distributing paper
ballots, staffing polling stations, and transporting and securing ballot boxes. This can
result in significant cost savings for governments and election commissions, which
can be redirected to other areas of public need.
Overall, an online voting system has the potential to improve the integrity,
accessibility, and efficiency of the democratic process, and ensure that all eligible
citizens have the opportunity to participate in the democratic process.
114
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
An online voting system also has several limitations and potential drawbacks that
must be considered before implementing such a system. Some of the key limitations
of an online voting system are:
2. Accessibility: While an online voting system may increase access to voting for
some people, it may also limit access for others who do not have reliable
internet access or who may face technical difficulties in using the system.
5. Trust and transparency: The lack of transparency in the online voting process
may also raise concerns about the fairness and legitimacy of the results, which
could undermine public trust in the democratic process.
115
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
The future scope of an online voting system project is vast, as it has the potential to
transform the democratic process by making it more accessible, efficient, and
accurate. Some of the key areas for future development and improvement in an online
voting system project are:
3. User experience: Improving the user experience and usability of the online
voting system is essential to ensure that voters can easily navigate the system
and cast their votes without facing technical difficulties or errors.
5. Integration with existing systems: Integrating the online voting system with
existing election infrastructure and systems, such as voter registration databases
or vote tabulation systems, can streamline the voting process and reduce the
potential for errors or discrepancies.
In conclusion, the future scope of an online voting system project is vast, and ongoing
development and improvement in security, accessibility, user experience, verification,
and integration with existing systems are critical to ensure the success and
effectiveness of such a system.
116
Name:-Students name here Roll No: 56
T.Y.B.Sc.IT Project title here
References:-
https://stackoverflow.com/questions/27825081/if-select-tag-option-is-selected-shows-
another-select-tag
https://www.tutorialspoint.com/index.htm
https://www.w3schools.com/
https://eci.gov.in/evm/
117
Name:-Students name here Roll No: 56