You are on page 1of 70

Globsyn finishing school, Globsyn Crystals, 1st Floor, XI – 11 and 12,

Block EP, Sector V, Salt Lake, Kolkata – 700091

Document sign date :Jul 30, 2017


E-CAB BOOKING

Group Members:
SAGNIK BHATTACHARYYA, ACADEMY OF TECNOLOGY, 141690110070.
SOMNATH KARMAKAR, GOVERNMENT COLLEGE OF ENGINEERING AND LEATHER TECHNOLOGY,141120110038.
DEEKSHA GOYAL, INSTITUTE OF ENGINEERING AND MANAGMENT, 151040110248.
SUBHAM CHOUDHARY, BENGAL OF ENGINEERING AND TECHNOLOGY, DURGAPUR, 141250110108.
RAJESH GUPTA, BENGAL COLLEGE OF ENGINEERING AND TECHNOLOGY, DURGAPUR, 141250110075.
SHAKIR ANSAIR, GOVERNMENT COLLEGE OF ENGINEERING AND LEATHER TECHNOLOGY, 141120110082.
ASHUTOSH MAHATO, GOVERNMENT COLLEGE OF ENGINEERING AND LEATHER TECHNOLOGY, 141120110008.
SOUMYOJIT SASMAL, GOVERNMENT COLLEGE OF ENGINEERING AND LEATHER TECHNOLOGY,151120120010.

www.globsynfinishingschool.com
1

Document sign date :Jul 30, 2017


Table of Contents

1. Acknowledgement...................................................................................................................... 3
2. Project Objective ........................................................................................................................ 4
3. Project Scope .............................................................................................................................. 5
4. Requirement Specification ......................................................................................................... 6
5. Database Design ......................................................................................................................... 7
6. Application Work Flow Diagram ............................................................................................... 10
7. Screenshots .............................................................................................................................. 11
8. Future Scope of Improvements ................................................................................................ 18
9. Code.......................................................................................................................................... 19
10. Project Certificate............................................................................................................ ........62

www.globsynfinishingschool.com
2

Document sign date :Jul 30, 2017


Acknowledgement

We take this opportunity to express our profound gratitude and deep regards
to our faculty Mr. Dayamay Halder for his exemplary guidance,monitoring
and constant encouragement throughout the course of this project. The
blessing, help and guidance given by him time to time shall carry us a long way
in the journey of life on which we are about to embark.

We are obliged to our project team members for the valuable information
provided by us in our respective fields. We are grateful for our cooperation
during the period of our assignment.

SAGNIK BHATTACHARYYA

SOMNATH KARMAKAR

DEEKSHA GOYAL

SUBHAM CHOUDHARY

RAJESH GUPTA

SHAKIR ANSAIR

ASHUTOSH MAHATO

SOUMYOJIT SASMAL

www.globsynfinishingschool.com
3

Document sign date :Jul 30, 2017


Project objective
The objective of this project is to automate vehicle rental and reservation so that customers
do need to call and spend unnecessary time in order to reserve a vehicle.

They can go online and reserve any kind of vehicle they want and that is available. Even
when a customer chooses to visit the booking centre to personally hire a vehicle,
computers are available for him to go online and perform his reservation . When he choose
to reserve by phone, any of the customer service representatives can help him reserve the
vehicle speedily, and issue hi, a reservation number.

The following Online Cab Booking having the following objectives:-

1. Enhance Business Processes: To be able to use internet technology to project the rental
company to the global world instead of limiting their services to their local domain alone,
thus increase their Return on Investment (ROI).

2. Traveller’s registration: A registration portal to hold traveller’s details, monitor their


transaction and used same to offer better and improve services to them.

3. Group bookings: Allows the customer to book space for a group in the case of weeding or
corporate parties or meetings.

4. Eco-friendly: The monitoring of the vehicle activity and the overall business becomes
easy and includes the least of paper work.

5. Availability: The software acts as an office that is open 24/7.

6. Efficient: It increases the efficiency of the management at offering quality services to the
customers.

7. User friendly: It provides custom features development and support with the software’s.

8. Security: The subsystem should provide a high level of security and integrity of the data
held by the system, only authorized personnel of the company can gain access to the
company’s secured page on the system; and only users with valid password and username
can login to view user’s page.

www.globsynfinishingschool.com
4

Document sign date :Jul 30, 2017


Project Scope

This project transverse a lot of areas ranging from business concepts to


computing field, & required to perform several researches to be able to
achieve the project objectives. The area covers include:

 Cab hiring industry: This includes study on how the cab booking
business is being done, process involved and opportunity that exist for
improvement.
 HTML Technology used for the development of the application.
 General customers/travellers as well as the company’s staffs will be
able to use the system efficiently.

www.globsynfinishingschool.com
5

Document sign date :Jul 30, 2017


Requirement Specification
Domain Description:- Cab Booking System.
Problem Definition:-This project shows how an E-Cab Booking System actually
works.

Functional Requirements:-

Hardware /Software Requirements


1. Hardware requirement:-
 Laptop
 Internet connection
 Pen drive
2. Software Requirement:-
 Client side :-Web browser
 Server side:-Tomcat Apache Server 7.0
 Eclipse
 My SQL
 JDK
 Jar Files

www.globsynfinishingschool.com
6

Document sign date :Jul 30, 2017


Database Design
create table userdata(user_id int auto_increment primary key,user_name varchar(30),user_mob_no bigint unique
not null,user_email varchar(30) not null unique,user_password varchar(20) not null,user_address varchar(50) not
null,user_dob varchar(10) not null,user_gender varchar(1),user_wallet_money int,user_no_of_rides int);

create table driverdata(driver_id int auto_increment primary key,driver_name varchar(30) not null,driver_mob_no
bigint unique not null,driver_email varchar(30) not null unique,driver_password varchar(20) not null,user_address
varchar(50) not null,driver_gender varchar(1) not null,driver_aadhar_card bigint not null
unique,driver_driving_license varchar(20) not null unique,car_no int);

Create table booking(booking_id int auto_increment primary key,driver_id int not null,user_id int not null,source
varchar(20) not null,destination varchar(20) not null,fare int not null,date varchar(20) not null,car_type varchar(20)
not null);

www.globsynfinishingschool.com
7

Document sign date :Jul 30, 2017


Create table car_details(car_no varchar(20) primary key,car_type varchar(20),driver_id int,status varchar(2));

create table distance(places varchar(20),Dumdum int,Belgachia int,ShyamBazar int,Sovabazar int,GirishPark


int,MahatmaGandhiRoad int,Central int,ChandniChowk int,Esplanade int,ParkStreet int);

www.globsynfinishingschool.com
8

Document sign date :Jul 30, 2017


Create table car_fare(car_type varchar(20) primary key,fare int not null,details varchar(50) not null);

www.globsynfinishingschool.com
9

Document sign date :Jul 30, 2017


Application Work Flow
Registered

New user
HOME/ LOGIN PAGE REGISTRATION PAGE

Logging in

Add money Edit profile


ADD MONEY Done BOOKING PAGE After editing EDIT PROFILE

Admin
Login

Driver’s Login

ADMIN LOGIN
DRIVER’S LOGIN
PAYMENT MODE

MANAGE MANAGE MANAGE


CHANGE STATUS USERS
DRIVER CARS

BOOKING CONFIRMED

www.globsynfinishingschool.com
10

Document sign date :Jul 30, 2017


Screenshots
Login page:-

Registration Page:-

www.globsynfinishingschool.com
11

Document sign date :Jul 30, 2017


Home Page:-

Payment Mode:-

www.globsynfinishingschool.com
12

Document sign date :Jul 30, 2017


Add Money:-

User edit profile:-

www.globsynfinishingschool.com
13

Document sign date :Jul 30, 2017


AdminLogin Page:-

Admin Page:-

www.globsynfinishingschool.com
14

Document sign date :Jul 30, 2017


Driver Details:-

User Details:-

www.globsynfinishingschool.com
15

Document sign date :Jul 30, 2017


User Information:-

Driver Registration:-

www.globsynfinishingschool.com
16

Document sign date :Jul 30, 2017


Driver Information:-

www.globsynfinishingschool.com
17

Document sign date :Jul 30, 2017


Future Scope of Improvements
FUTURE SCOPE OF APPLICATION:

This application can be easily implemented under various situations . We can add new features
as and when we require. Reusability is possible as and when require in this application. There is
flexibility in all the modules.

SOFTWARE SCOPE:

 Extensibility:The following principles enhances extensibility like hide data structure ,


avoid traversing multiple links or methods , avoid case statements on object type and
distinguish public and private operations.

 Reusability: Reusability is possible as and when require in this application . We can


update it next version. Reusable software over several designs. Reducing the amount of
code also simplifies understanding , which increases the likelihood that the code is
correct . We follow up both types of reusability. Sharing of newly written code within a
project and reuse of previously written code on new projects.

 Understandability: A method is understandable if someone other than the creator of


the method can understand the code (as well as the creator after a time lapse). We use
the method , which small and coherent helps to accomplish this.

 Cost-effectiveness: Its cost is under the budget and make within given time period. It is
desirable to aim for a system with a minimum cost subject to the condition that it must
satisfy the entire-requirement.

www.globsynfinishingschool.com
18

Document sign date :Jul 30, 2017


Code
Login Servlet:

package com.globsyn.ecabproject.user;

import java.io.IOException;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.globsyn.ecabproject.user.User;

public class LoginServlet extends HttpServlet {


private static final long serialVersionUID = 1L;

public LoginServlet() {
super();
}

java.sql.Connection con;
java.sql.PreparedStatement st;

public void init() {

ServletConfig config = getServletConfig();

String driver = config.getServletContext().getInitParameter("driver");


String url = config.getServletContext().getInitParameter("url");
String user = config.getServletContext().getInitParameter("username");
String passwd = config.getServletContext().getInitParameter("password");

try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}

try {
con = DriverManager.getConnection(url, user, passwd);
} catch (SQLException e) {
e.printStackTrace();
}

www.globsynfinishingschool.com
19

Document sign date :Jul 30, 2017


String query = "select * from userdata where user_mob_no = ?";
try {
st = ((java.sql.Connection) con).prepareStatement(query);
} catch (SQLException e) {
e.printStackTrace();
}
}

RequestDispatcher rd;

protected void doPost(HttpServletRequest request, HttpServletResponse response)


throws ServletException, IOException {
// TODO Auto-generated method stub

String username = request.getParameter("username");


String upassword = request.getParameter("password");

// String user ;
String message = "";
String userId = "" ;
String userName = "";
String gender ="";
String dob ="";
String mobile ="";
String city ="";
String address="" ;
String email="" ;
String password ="";
String walletmoney ="";
String rides ="";

ResultSet rs;
try {
st.setString(1, username);
rs = st.executeQuery();
if (rs.next()) {
userId = rs.getString(1);
userName = rs.getString(2);
mobile = rs.getString(3);
email = rs.getString(4);
password = rs.getString(5);
address = rs.getString(6);
dob = rs.getString(7);
gender = rs.getString(8);
walletmoney = rs.getString(9);
rides = rs.getString(10);
}
} catch (SQLException e) {
e.printStackTrace();
}
if(username == "" && upassword == ""){
message = "**invalid userId and Password**";

www.globsynfinishingschool.com
20

Document sign date :Jul 30, 2017


rd = request.getRequestDispatcher("Login.jsp");
request.setAttribute("key", message);
}
else
{
if (password.equals(upassword)) {
HttpSession session = request.getSession();
User userloggedin = new User(userId, userName, mobile, email, password, address, dob,
gender, city, walletmoney, rides);

session.setAttribute("userloggedin",userloggedin);

rd = request.getRequestDispatcher("/HomePage.jsp");
} else {
message = "**Wrong userId and Password.Try again**";
rd = request.getRequestDispatcher("Login.jsp");
request.setAttribute("key", message);
}
}
rd.forward(request, response);

protected void doGet(HttpServletRequest request, HttpServletResponse response)


throws ServletException, IOException {
doPost(request, response);
}

public void destroy() {


try {
con.close();
st.close();
} catch (SQLException e) {
e.printStackTrace();
}
}

RegistrationServlet:
package com.globsyn.ecabproject.user;

import java.io.IOException;
import java.sql.DriverManager;
import java.sql.SQLException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

www.globsynfinishingschool.com
21

Document sign date :Jul 30, 2017


public class Registration extends HttpServlet {
private static final long serialVersionUID = 1L;

public Registration() {
super();
}
String message ;
java.sql.Connection con ;
java.sql.Statement st ;
public void init(){

ServletConfig config = getServletConfig();

String driver = config.getServletContext().getInitParameter("driver");


String url = config.getServletContext().getInitParameter("url");
String user = config.getServletContext().getInitParameter("username");
String passwd = config.getServletContext().getInitParameter("password");

try{
Class.forName(driver);
}catch(ClassNotFoundException e){
e.printStackTrace();
}

try{
con = DriverManager.getConnection(url,user,passwd);
}catch(SQLException e){
e.printStackTrace();
}

//String insertsql = "insert into userdatabase values(?,?,?,?,?,?,?,?);";


try{
st = con.createStatement();
}catch(SQLException e){
e.printStackTrace();
}
}

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,


IOException {
doPost(request, response);
}

RequestDispatcher rd ;

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws


ServletException, IOException {

String userName = request.getParameter("UserName");


String gender = request.getParameter("Gender");
String dob = request.getParameter("UserDob");
String mobile = request.getParameter("UserMob");
String address = request.getParameter("UserAddress");
String email = request.getParameter("UserEmail");
String password = request.getParameter("UserPassword");
String password1 = request.getParameter("UserPassword1");

if(password.equals(password1)){

www.globsynfinishingschool.com
22

Document sign date :Jul 30, 2017


try {
/*st.setString(1,userName);
st.setString(2,gender);
st.setString(3,dob);
st.setString(4,mobile);
st.setString(5,city);
st.setString(6,address);
st.setString(7,email);
st.setString(8,password);*/
string insertsql =
"insert into userdata(user_name,user_gender,user_dob,user_mob_no,user_address,user_email,user_password)
values('"+userName+"','"+gender+"','"+dob
+"',"+Long.valueOf(mobile).longValue()+",'"+address+"','"+email+"','"+password+"')";

st.executeUpdate(insertsql);

message = "Registration Successful.Login here";


request.setAttribute("key",message);
rd = request.getRequestDispatcher("/Login.jsp");
} catch (SQLException e) {
e.printStackTrace();
}

}else{
message = "**Passwords not matched.Try again**";
rd = request.getRequestDispatcher("/Registration.jsp");
request.setAttribute("key", message);
}

rd.forward(request,response);

}
public void destroy(){
try{
con.close();
st.close();
}catch(SQLException e){
e.printStackTrace();
}
}

EditProfileServlet:
package com.globsyn.ecabproject.user;

import java.io.IOException;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

www.globsynfinishingschool.com
23

Document sign date :Jul 30, 2017


public class EditProfile extends HttpServlet {
private static final long serialVersionUID = 1L;
public EditProfile() {
super();
}

String message;
java.sql.Connection con;
java.sql.PreparedStatement st;
java.sql.PreparedStatement pst;
public void init() {

ServletConfig config = getServletConfig();

String driver = config.getServletContext().getInitParameter("driver");


String url = config.getServletContext().getInitParameter("url");
String user = config.getServletContext().getInitParameter("username");
String passwd = config.getServletContext().getInitParameter("password");

try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}

try {
con = DriverManager.getConnection(url, user, passwd);
} catch (SQLException e) {
e.printStackTrace();
}

String insertsql = "update userdata set user_address=?,user_email=?,user_password=? where


user_mob_no =?";
String query = "select * from userdata where user_mob_no = ?";
try {
st = con.prepareStatement(insertsql);
pst = con.prepareStatement(query);
} catch (SQLException e) {
e.printStackTrace();
}
}

protected void doGet(HttpServletRequest request, HttpServletResponse response)


throws ServletException, IOException {
doPost(request, response);
}

RequestDispatcher rd;

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws


ServletException, IOException {

HttpSession session = request.getSession();


User userloggedin =(User) session.getAttribute("userloggedin");

String mobile = userloggedin.getMobile();


String address = request.getParameter("address");
String email = request.getParameter("email");
String oldpassword = request.getParameter("oldpassword");
String newpassword = request.getParameter("newpassword");

www.globsynfinishingschool.com
24

Document sign date :Jul 30, 2017


String newpassword1 = request.getParameter("newpassword1");

ResultSet rs ;
String passwd ="";
try{
pst.setString(1,mobile);
rs = pst.executeQuery();
if(rs.next()){
passwd = rs.getString("user_password");
}
}catch(SQLException e){
e.printStackTrace();
}
System.out.println(passwd + " "+oldpassword);
if(passwd.equals(oldpassword)){
try {
if(newpassword.equals(newpassword1)){

st.setString(1,address);
st.setString(2,email);
st.setString(3,newpassword);
st.setString(4,mobile);

st.executeUpdate();
message = "Database Updated";
rd = request.getRequestDispatcher("/HomePage.jsp");
request.setAttribute("key",message);
}else{
message ="New Passwords do not match.Try again";
rd = request.getRequestDispatcher("/EditProfile.jsp");
request.setAttribute("key",message);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}else{

message ="Old Password does not match.try again";


rd = request.getRequestDispatcher("EditProfile.jsp");
request.setAttribute("key",message);
}

rd.forward(request,response);
}

public void destroy() {


try {
con.close();
st.close();
} catch (SQLException e) {
e.printStackTrace();
}
}

AddMoneyServlet:
package com.globsyn.ecabproject.user;

www.globsynfinishingschool.com
25

Document sign date :Jul 30, 2017


import java.io.IOException;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class EditProfile extends HttpServlet {


private static final long serialVersionUID = 1L;

public EditProfile() {
super();
}
string message;

java.sql.Connection con;
java.sql.PreparedStatement st;
java.sql.PreparedStatement pst;

public void init() {

ServletConfig config = getServletConfig();

String driver = config.getServletContext().getInitParameter("driver");


String url = config.getServletContext().getInitParameter("url");
String user = config.getServletContext().getInitParameter("username");
String passwd = config.getServletContext().getInitParameter("password");

try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}

try {
con = DriverManager.getConnection(url, user, passwd);
} catch (SQLException e) {
e.printStackTrace();
}

String insertsql = "update userdata set user_address=?,user_email=?,user_password=? where


user_mob_no =?";
String query = "select * from userdata where user_mob_no = ?";
try {
st = con.prepareStatement(insertsql);
pst = con.prepareStatement(query);
} catch (SQLException e) {
e.printStackTrace();
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}

RequestDispatcher rd;

www.globsynfinishingschool.com
26

Document sign date :Jul 30, 2017


protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {

HttpSession session = request.getSession();


User userloggedin =(User) session.getAttribute("userloggedin");

String mobile = userloggedin.getMobile();


String address = request.getParameter("address");
String email = request.getParameter("email");
String oldpassword = request.getParameter("oldpassword");
String newpassword = request.getParameter("newpassword");
String newpassword1 = request.getParameter("newpassword1");

ResultSet rs ;
String passwd ="";
try{
pst.setString(1,mobile);
rs = pst.executeQuery();
if(rs.next()){
passwd = rs.getString("user_password");
}
}catch(SQLException e){
e.printStackTrace();

}
System.out.println(passwd + " "+oldpassword);
if(passwd.equals(oldpassword)){

try {
if(newpassword.equals(newpassword1)){

st.setString(1,address);
st.setString(2,email);
st.setString(3,newpassword);
st.setString(4,mobile);

st.executeUpdate();
message = "Database Updated";
rd = request.getRequestDispatcher("/HomePage.jsp");
request.setAttribute("key",message);
}else{
message ="New Passwords do not match.Try again";
rd = request.getRequestDispatcher("/EditProfile.jsp");
request.setAttribute("key",message);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}else{

message ="Old Password does not match.try again";


rd = request.getRequestDispatcher("EditProfile.jsp");
request.setAttribute("key",message);
}

rd.forward(request,response);
}

www.globsynfinishingschool.com
27

Document sign date :Jul 30, 2017


public void destroy() {
try {
con.close();
st.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
ForgotPasswordServlet:
package com.globsyn.ecabproject.user;

import java.io.IOException;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ForgotPassword extends HttpServlet {


private static final long serialVersionUID = 1L;

public ForgotPassword() {
super();
}

java.sql.Connection con ;
java.sql.PreparedStatement st ;

public void init(){


String driver ;
String url ;
String user ;
String passwd ;
ServletConfig config = getServletConfig();

driver = config.getServletContext().getInitParameter("driver");
url = config.getServletContext().getInitParameter("url");
user = config.getServletContext().getInitParameter("username");
passwd = config.getServletContext().getInitParameter("password");

try{
Class.forName(driver);
}catch(ClassNotFoundException e){
e.printStackTrace();
}

try{
con = DriverManager.getConnection(url,user,passwd);
}catch(SQLException e){
e.printStackTrace();
}
String query = "select * from userdata where user_mob_no = ?";
try{
st = ((java.sql.Connection) con).prepareStatement(query);

www.globsynfinishingschool.com
28

Document sign date :Jul 30, 2017


}catch(SQLException e){
e.printStackTrace();
}
}

RequestDispatcher rd;

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,


IOException {
doPost(request,response);
}

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws


ServletException, IOException {
String user = request.getParameter("UserMob");
String dob = request.getParameter("UserDob");

String userDob = "";


String userPassword = "";
String message = "";
ResultSet rs ;

try {
st.setLong(1,Long.valueOf(user).longValue());
rs = st.executeQuery();
if(rs.next()){
userDob = rs.getString("user_dob");
userPassword = rs.getString("user_password");
}
} catch (SQLException e) {
e.printStackTrace();
}
if(dob.equals(userDob)){
message = "your login password = "+userPassword;
rd = request.getRequestDispatcher("/Login.jsp");
request.setAttribute("key",message);

}else
{

message = "**UserId and DOB not matched.Try again**";


rd = request.getRequestDispatcher("/ForgotPassword.jsp");
request.setAttribute("key",message);

rd.forward(request,response);
}

}
UserServlet

package com.globsyn.ecabproject.user;

www.globsynfinishingschool.com
29

Document sign date :Jul 30, 2017


public class User {
private String userId ;
private String userName;
private String mobile ;
private String email ;
private String password ;
private String address ;
private String dob ;
private String gender ;
private String city ;
private String walletmoney;
private String rides ;

public User(){
}

public User(String userId, String userName, String mobile, String email, String password, String address,
String dob, String gender, String city, String walletmoney, String rides) {
super();
this.userId = userId;
this.userName = userName;
this.mobile = mobile;
this.email = email;

this.password = password;
this.address = address;
this.dob = dob;
this.gender = gender;
this.city = city;
this.walletmoney = walletmoney;
this.rides = rides;
}

public String getUserId() {


return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getDob() {
return dob;
}
public void setDob(String dob) {
this.dob = dob;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getCity() {
return city;
}

www.globsynfinishingschool.com
30

Document sign date :Jul 30, 2017


public void setCity(String city) {
this.city = city;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getWalletmoney() {
return walletmoney;
}
public void setWalletmoney(String walletmoney) {
this.walletmoney = walletmoney;
}
public String getRides() {
return rides;
}

public void setRides(String rides) {


this.rides = rides;
}

public String getUserName() {


return userName;
}

public void setUserName(String userName) {


this.userName = userName;
}

LogoutServlet:
package com.globsyn.ecabproject.user;

import java.io.IOException;

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 javax.servlet.http.HttpSession;

@WebServlet("/LogoutServlet")
public class LogoutServlet extends HttpServlet {

www.globsynfinishingschool.com
31

Document sign date :Jul 30, 2017


private static final long serialVersionUID = 1L;

public LogoutServlet() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
doPost(request,response);
}

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws


ServletException, IOException {

HttpSession session = request.getSession();


session.invalidate();

request.getRequestDispatcher("Login.jsp").forward(request, response);

}
DriverLoginServlet:
package com.globsyn.ecabproject.driver;

import java.io.IOException;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
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 javax.servlet.http.HttpSession;

import com.globsyn.ecabproject.driver.Driver;
@WebServlet("/DriverLogIn")
public class DriverLogIn extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public DriverLogIn() {
super();
// TODO Auto-generated constructor stub
}

java.sql.Connection con;
java.sql.PreparedStatement st;
java.sql.PreparedStatement pst;
public void init() {
String driver;

www.globsynfinishingschool.com
32

Document sign date :Jul 30, 2017


String url;
String user;
String passwd;
ServletConfig config = getServletConfig();

driver = config.getServletContext().getInitParameter("driver");
url = config.getServletContext().getInitParameter("url");
user = config.getServletContext().getInitParameter("username");
passwd = config.getServletContext().getInitParameter("password");
try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
try {
con = DriverManager.getConnection(url, user, passwd);
} catch (SQLException e) {
e.printStackTrace();
}
String query = "select * from driverdata where driver_mob_no = ?";
String check="select * from car_details where car_no=?";
try {
st = con.prepareStatement(query);
pst=con.prepareStatement(check);
} catch (SQLException e) {
e.printStackTrace();
}

RequestDispatcher rd;

protected void doPost(HttpServletRequest request, HttpServletResponse response)


throws ServletException, IOException {
// TODO Auto-generated method stub
String message = "";
String mobile = request.getParameter("mobile");
String upassword = request.getParameter("password");
if (!mobile.equals("") && !upassword.equals("")) {

// String user ;
String id="";
String password = "";
String name = "";
String mob_no = "";
String email = "";
String address = "";
String gender = "";
String aadharcard = "";
String drivinglicense = "";
String carno="";

ResultSet rs;
try {
st.setString(1, mobile);
rs = st.executeQuery();
if (rs.next()) {

www.globsynfinishingschool.com
33

Document sign date :Jul 30, 2017


id = rs.getString("drive_id");
name = rs.getString("driver_name");
password = rs.getString("driver_password");
mob_no = rs.getString("driver_mob_no");
email = rs.getString("driver_email");
address = rs.getString("driver_address");
gender = rs.getString("driver_gender");
carno = rs.getString("car_no");
aadharcard = rs.getString("driver_aadhar_card");
drivinglicense=rs.getString("driver_driving_license");
if (password.equals(upassword)) {
HttpSession session = request.getSession();
Driver driver=new Driver(id,name, mob_no,email,password,
address,gender,aadharcard, drivinglicense, carno);
session.setAttribute("driver", driver);
pst.setString(1,carno);
rs=pst.executeQuery();
message = rs.getString("status");
request.setAttribute("key", message);
rd = request.getRequestDispatcher("/DriverStatusPage.jsp");
} else {
message = "Wrong Password.Try again";
rd = request.getRequestDispatcher("DriverLogin.jsp");
request.setAttribute("key", message);
}
}else {
message = "Wrong Mobile No and Password.Try again";
rd = request.getRequestDispatcher("DriverLogin.jsp");
request.setAttribute("key", message);
}
} catch (SQLException e) {
e.printStackTrace();
}

} else {
message = "Please enter all the credentials";
rd = request.getRequestDispatcher("DriverLogin.jsp");
request.setAttribute("key", message);
}

rd.forward(request, response);

protected void doGet(HttpServletRequest request, HttpServletResponse response)


throws ServletException, IOException {
doPost(request, response);
}

public void destroy() {


try {
con.close();
st.close();
} catch (SQLException e) {
e.printStackTrace();
}
}

www.globsynfinishingschool.com
34

Document sign date :Jul 30, 2017


}

DriverServlet:
package com.globsyn.ecabproject.driver;

public class Driver {


private String driver_id;
private String driver_name;
private String driver_mob_no;
private String driver_email;
private String driver_password;
private String driver_address;
private String driver_gender;
private String driver_aadhar_no;
private String driver_licence_no;
private String driver_car_no;

public void Driver(){


}

public Driver(String driver_id, String driver_name, String driver_mob_no, String driver_email,


String driver_password, String driver_address, String driver_gender, String
driver_aadhar_no,
String driver_licence_no, String driver_car_no) {
super();
this.driver_id = driver_id;
this.driver_name = driver_name;
this.driver_mob_no = driver_mob_no;
this.driver_email = driver_email;
this.driver_password = driver_password;
this.driver_address = driver_address;
this.driver_gender = driver_gender;
this.driver_aadhar_no = driver_aadhar_no;
this.driver_licence_no = driver_licence_no;
this.driver_car_no = driver_car_no;
}

public String getDriver_id() {


return driver_id;
}

public void setDriver_id(String driver_id) {


this.driver_id = driver_id;
}

public String getDriver_name() {


return driver_name;
}

public void setDriver_name(String driver_name) {


this.driver_name = driver_name;
}

www.globsynfinishingschool.com
35

Document sign date :Jul 30, 2017


public String getDriver_mob_no() {
return driver_mob_no;
}

public void setDriver_mob_no(String driver_mob_no) {


this.driver_mob_no = driver_mob_no;
}

public String getDriver_email() {


return driver_email;
}

public void setDriver_email(String driver_email) {


this.driver_email = driver_email;
}

public String getDriver_password() {


return driver_password;
}

public void setDriver_password(String driver_password) {


this.driver_password = driver_password;
}
public String getDriver_address() {
return driver_address;
}

public void setDriver_address(String driver_address) {


this.driver_address = driver_address;
}

public String getDriver_gender() {


return driver_gender;
}

public void setDriver_gender(String driver_gender) {


this.driver_gender = driver_gender;
}

public String getDriver_aadhar_no() {


return driver_aadhar_no;
}

public void setDriver_aadhar_no(String driver_aadhar_no) {


this.driver_aadhar_no = driver_aadhar_no;
}

public String getDriver_licence_no() {


return driver_licence_no;
}

www.globsynfinishingschool.com
36

Document sign date :Jul 30, 2017


public void setDriver_licence_no(String driver_licence_no) {
this.driver_licence_no = driver_licence_no;
}

public String getDriver_car_no() {


return driver_car_no;
}

public void setDriver_car_no(String driver_car_no) {


this.driver_car_no = driver_car_no;
}

ChangeStatusServlet:
package com.globsyn.ecabproject.driver;
import java.io.IOException;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
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 javax.servlet.http.HttpSession;

import com.globsyn.ecabproject.driver.Driver;

@WebServlet("/DriverLogIn")
public class ChangeStatus extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public ChangeStatus() {
super();
// TODO Auto-generated constructor stub
}

java.sql.Connection con;
java.sql.PreparedStatement st;
java.sql.PreparedStatement pst;
public void init() {
String driver;
String url;
String user;
String passwd;
ServletConfig config = getServletConfig();

driver = config.getServletContext().getInitParameter("driver");
url = config.getServletContext().getInitParameter("url");
user = config.getServletContext().getInitParameter("username");
passwd = config.getServletContext().getInitParameter("password");

www.globsynfinishingschool.com
37

Document sign date :Jul 30, 2017


try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
try {
con = DriverManager.getConnection(url, user, passwd);
} catch (SQLException e) {
e.printStackTrace();
}
String query = "update car_details set status=? where car_no=?";
String check="select * from car_details where car_no=?";
try {
st = con.prepareStatement(query);
pst=con.prepareStatement(check);
} catch (SQLException e) {
e.printStackTrace();
}
}

RequestDispatcher rd;

protected void doPost(HttpServletRequest request, HttpServletResponse response)


throws ServletException, IOException {
// TODO Auto-generated method stub
String message = "";
HttpSession session=request.getSession();
Driver driver=(Driver)session.getAttribute("driver");
try {
pst.setString(1, driver.getDriver_car_no());
ResultSet rs=pst.executeQuery();
if(rs.getString("status").equals("NA"))
{
st.setString(1,"A");
}
else
st.setString(1,"NA");
st.setString(2,driver.getDriver_car_no());
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

rd.forward(request, response);

}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}

public void destroy() {


try {
con.close();
st.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}

www.globsynfinishingschool.com
38

Document sign date :Jul 30, 2017


CarServlet:
package com.globsyn.ecabproject.car;

public class Car {


private String car_no;
private String car_type;
private String driver_id;
private String status;
public void Car(){

public Car(String car_no, String car_type, String driver_id, String status) {


super();
this.car_no = car_no;
this.car_type = car_type;
this.driver_id = driver_id;
this.status = status;
}

public String getCar_no() {


return car_no;
}

public void setCar_no(String car_no) {


this.car_no = car_no;
}

public String getCar_type() {


return car_type;
}

public void setCar_type(String car_type) {


this.car_type = car_type;
}

public String getDriver_id() {


return driver_id;
}
public void setDriver_id(String driver_id) {
this.driver_id = driver_id;
}

public String getStatus() {


return status;
}

public void setStatus(String status) {


this.status = status;
}

CarDetailsServlet:
package com.globsyn.ecabproject.car;

www.globsynfinishingschool.com
39

Document sign date :Jul 30, 2017


import java.io.IOException;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
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 javax.servlet.http.HttpSession;

import com.globsyn.ecabproject.user.User;

@WebServlet("/CarDetails")
public class CarDetails extends HttpServlet {
private static final long serialVersionUID = 1L;

public CarDetails() {
super();
}

java.sql.Connection con;
java.sql.PreparedStatement st;

public void init() {

ServletConfig config = getServletConfig();

String driver = config.getServletContext().getInitParameter("driver");


String url = config.getServletContext().getInitParameter("url");
String user = config.getServletContext().getInitParameter("username");
String passwd = config.getServletContext().getInitParameter("password");

try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
try {
con = DriverManager.getConnection(url, user, passwd);
} catch (SQLException e) {
e.printStackTrace();
}
String query = "select * from car_details";
try {
st = ((java.sql.Connection) con).prepareStatement(query);
} catch (SQLException e) {
e.printStackTrace();
}
}

RequestDispatcher rd;

www.globsynfinishingschool.com
40

Document sign date :Jul 30, 2017


protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
doPost(request, response);
}

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws


ServletException, IOException {

String carNo = "" ;


String carType = "";
String driverId ="";
String status = "";
ResultSet rs;
ArrayList<Car> carList = new ArrayList<Car>();
try {
rs = st.executeQuery();
while(rs.next()) {
carNo = rs.getString(1);
carType = rs.getString(2);
driverId = rs.getString(3);
status = rs.getString(4);
System.out.println(carNo);
Car car = new Car(carNo,carType,driverId,status);
carList.add(car);
}
} catch (SQLException e) {
e.printStackTrace();
}

HttpSession session = request.getSession();


request.getSession().setAttribute("cardata",carList);
//System.out.println(x);
request.getRequestDispatcher("/CarDetails.jsp").forward(request, response);;

public void destroy() {


try {
con.close();
st.close();
} catch (SQLException e) {
e.printStackTrace();
}
}

AddCarServlet:
package com.globsyn.ecabproject.car;

import java.io.IOException;

import java.sql.DriverManager;
import java.sql.SQLException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;

www.globsynfinishingschool.com
41

Document sign date :Jul 30, 2017


import javax.servlet.http.HttpServletResponse;

@WebServlet("/AddCar")
public class AddCar extends HttpServlet {
private static final long serialVersionUID = 1L;

public AddCar()
super();
// TODO Auto-generated constructor stub
}
java.sql.Connection con;
java.sql.PreparedStatement st;

public void init() {


ServletConfig config = getServletConfig();

String driver = config.getServletContext().getInitParameter("driver");


String url = config.getServletContext().getInitParameter("url");
String user = config.getServletContext().getInitParameter("username");
String passwd = config.getServletContext().getInitParameter("password");

try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}

try {
con = DriverManager.getConnection(url, user, passwd);
} catch (SQLException e) {
e.printStackTrace();
}
String insert = "insert into car_details(car_no,car_type) values(?,?)";
try {
st = ((java.sql.Connection) con).prepareStatement(insert);
} catch (SQLException e) {
e.printStackTrace();
}
}

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,


IOException {
doPost(request,response);
}

RequestDispatcher rd;
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {

String carNo = request.getParameter("carNo");


String carName = request.getParameter("carName");
try {
st.setString(1,carNo);
st.setString(2,carName);

st.executeUpdate();
rd = request.getRequestDispatcher("Administration.jsp");
request.setAttribute("key","Car added successfully.");
} catch (SQLException e) {
e.printStackTrace();
}

www.globsynfinishingschool.com
42

Document sign date :Jul 30, 2017


rd.forward(request, response);

public void destroy() {


try {
con.close();
st.close();

} catch (SQLException e) {
e.printStackTrace();
}
}

BookingServlet:
package com.globsyn.ecabproject.controller;

import java.io.IOException;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/Booking")
public class Booking extends HttpServlet {
private static final long serialVersionUID = 1L;

public Booking() {
super();
// TODO Auto-generated constructor stub
}
java.sql.Connection con;
java.sql.PreparedStatement st;
java.sql.PreparedStatement pst;
java.sql.PreparedStatement pst1;
public void init() {
String driver;
String url;
String user;
String passwd;
ServletConfig config = getServletConfig();

www.globsynfinishingschool.com
43

Document sign date :Jul 30, 2017


driver = config.getServletContext().getInitParameter("driver");
url = config.getServletContext().getInitParameter("url");
user = config.getServletContext().getInitParameter("username");
passwd = config.getServletContext().getInitParameter("password");

try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}

try {
con = DriverManager.getConnection(url, user, passwd);
} catch (SQLException e) {
e.printStackTrace();
}

RequestDispatcher rd;

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws


ServletException, IOException {

// TODO Auto-generated method stub


//doGet(request, response);
String source = request.getParameter("source");
String destination = request.getParameter("destination");
String ride = request.getParameter("ride");
String cartype = request.getParameter("cartype");
String query = "select * from distance where places=?";
String check="select * from car_details where car_type=? and status='A'";
String change = "update car_details set status=? where car_no =?";

try {
st = con.prepareStatement(query);
pst = con.prepareStatement(check);
pst1 = con.prepareStatement(change);

} catch (SQLException e) {
e.printStackTrace();
}
String message ="",message1="";
ResultSet rs = null;
int distance=0,price=100;

try {
pst.setString(1,cartype);

rs = pst.executeQuery();
if(rs.next())
{

pst1.setString(1,"NA");
pst1.setString(2,rs.getString("car_no"));

pst1.executeUpdate();

www.globsynfinishingschool.com
44

Document sign date :Jul 30, 2017


try {
st.setString(1,source);
rs = st.executeQuery();
if(rs.next())
{
distance=rs.getInt(destination);
}
else
message="wrong";
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
message =""+distance;
request.setAttribute("key", message);
if(cartype.equals("sedan"))
price+=30*distance;
if(cartype.equals("mini"))
price+=20*distance;
if(cartype.equals("lux"))
price+=50*distance;
message1+=price;
request.setAttribute("key1", message1);

rd = request.getRequestDispatcher("/PaymentMode.jsp");
}else
{
message ="Car Not Available";
request.setAttribute("key", message);
rd = request.getRequestDispatcher("/HomePage.jsp");

} catch (SQLException e1) {


// TODO Auto-generated catch block
e1.printStackTrace();
}
rd.forward(request,response);

}
public void destroy() {
try {
con.close();
st.close();
} catch (SQLException e) {
e.printStackTrace();
}
}

BookingPojoServlet:

package com.globsyn.ecabproject.controller;

public class BookingPojo {


String driverid;
String userid;

www.globsynfinishingschool.com
45

Document sign date :Jul 30, 2017


String source;
String destination;
String fare;
String cartype;
String date;
String carno;
public String getCarno() {
return carno;
}
public void setCarno(String carno) {
this.carno = carno;
}

public BookingPojo(String driverid, String userid, String source, String destination, String fare, String
cartype,
String date, String carno) {
super();
this.driverid = driverid;
this.userid = userid;
this.source = source;
this.destination = destination;
this.fare = fare;
this.cartype = cartype;
this.date = date;
this.carno = carno;
}
public BookingPojo(String driverid, String userid, String source, String destination, String fare, String date,
String cartype) {
super();
this.driverid = driverid;
this.userid = userid;
this.source = source;
this.destination = destination;
this.fare = fare;
this.date = date;
this.cartype = cartype;
}
public String getDriverid() {
return driverid;
}
public void setDriverid(String driverid) {
this.driverid = driverid;
}

public String getUserid() {


return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getDestination() {
return destination;

www.globsynfinishingschool.com
46

Document sign date :Jul 30, 2017


}
public void setDestination(String destination) {
this.destination = destination;
}
public String getFare() {
return fare;
}
public void setFare(String fare) {
this.fare = fare;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getCartype() {
return cartype;
}
public void setCartype(String cartype) {
this.cartype = cartype;
}
}

PaymentServlet:
package com.globsyn.ecabproject.controller;

import java.io.IOException;
import java.sql.DriverManager;
import java.sql.SQLException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
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 javax.servlet.http.HttpSession;

import com.globsyn.ecabproject.user.User;

@WebServlet("/Payment")
public class Payment extends HttpServlet {
private static final long serialVersionUID = 1L;
java.sql.Connection con;
java.sql.PreparedStatement st;
java.sql.PreparedStatement pst1;
java.sql.PreparedStatement pst2;
/**
* @see HttpServlet#HttpServlet()
*/
public Payment() {
super();
// TODO Auto-generated constructor stub
}
public void init() {

ServletConfig config = getServletConfig();

www.globsynfinishingschool.com
47

Document sign date :Jul 30, 2017


String driver = config.getServletContext().getInitParameter("driver");
String url = config.getServletContext().getInitParameter("url");
String user = config.getServletContext().getInitParameter("username");
String passwd = config.getServletContext().getInitParameter("password");

try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}

try {
con = DriverManager.getConnection(url, user, passwd);
} catch (SQLException e) {
e.printStackTrace();
}

}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
RequestDispatcher rd;
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {

// TODO Auto-generated method stub


String mode=request.getParameter("paymode");
HttpSession session=request.getSession();
BookingPojo booking=(BookingPojo)session.getAttribute("booking");
String cartype=booking.getCartype();
String carno=booking.getCarno();
String fare=booking.getFare();
String change = "update car_details set status=? where car_no =?";
String insert="insert into
booking(driver_id,user_id,source,destination,fare,date,car_type)values(?,?,?,?,?,?,?)";
try {
pst1 = con.prepareStatement(change);
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
String message;
if(mode.equals("cash"))
{
try {
pst1.setString(1,"NA");
pst1.setString(2,carno);

pst1.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();

www.globsynfinishingschool.com
48

Document sign date :Jul 30, 2017


}
try {
pst2=con.prepareStatement(insert);
pst2.setInt(1,Integer.parseInt(booking.getDriverid()));
pst2.setInt(2,Integer.parseInt(booking.getUserid()));
pst2.setString(3,booking.getSource());
pst2.setString(4,booking.getDestination());
pst2.setInt(5,Integer.parseInt(booking.getFare()));
pst2.setString(6,booking.getDate());
pst2.setString(7,booking.getCartype());
pst2.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
message = "Phone no";
rd = request.getRequestDispatcher("BookingDetails.jsp");
request.setAttribute("key", message);
}
if(mode.equals("wallet"))
{

User user=(User)session.getAttribute("key");
int wallet=Integer.parseInt(user.getWalletmoney());
int fare1=Integer.parseInt(fare);

if(wallet>fare1)
{
try {
pst1.setString(1,"NA");
pst1.setString(2,carno);

pst1.executeUpdate();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

String insertsql = "update userdata set user_wallet_money=? where


user_mob_no =?";

try {
st = con.prepareStatement(insertsql);
} catch (SQLException e) {
e.printStackTrace();
}
try {
st.setString(1, "" + (wallet - fare1));
st.setString(2, user.getMobile());
} catch (SQLException e) {
// TODO: handle exception
}
try {
st.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
user.setWalletmoney( "" + (wallet - fare1));
message = "Phone no";
rd = request.getRequestDispatcher("BookingDetails.jsp");
request.setAttribute("key", message);

www.globsynfinishingschool.com
49

Document sign date :Jul 30, 2017


}

else{
System.out.println("no");
message = "You don't have suffiecient wallet money";
rd = request.getRequestDispatcher("/HomePage.jsp");
request.setAttribute("key", message);
}

}
rd.forward(request, response);
}
}

AdminLoginServlet:
package com.globsyn.ecabproject.admin;

import java.io.IOException;

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 javax.servlet.http.HttpSession;

@WebServlet("/AdminLoginServlet")
public class AdminLoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

public AdminLoginServlet() {
super();
}
RequestDispatcher rd ;
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {

String adminId = request.getParameter("adminId");


String adminPassword = request.getParameter("adminPassword");
String id = getServletContext().getInitParameter("AdminId");
String password = getServletContext().getInitParameter("AdminPassword");
String message ;
if(adminId.equals(id) && adminPassword.equals(password)){
rd = request.getRequestDispatcher("/Administration.jsp");

HttpSession session = request.getSession();


session.setAttribute("adminId",adminId);

}else{
message = "**Wrong Id and Password**";
request.setAttribute("key",message);
rd = request.getRequestDispatcher("AdminLogin.jsp");
}

rd.forward(request, response);

www.globsynfinishingschool.com
50

Document sign date :Jul 30, 2017


}

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,


IOException {
// TODO Auto-generated method stub
doPost(request, response);
}

AdminServlet:

package com.globsyn.ecabproject.admin;

import java.io.IOException;
import java.sql.DriverManager;
import java.sql.SQLException;

import javax.security.auth.message.callback.PrivateKeyCallback.Request;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
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 javax.servlet.http.HttpSession;

@WebServlet("/AdminServlet")
public class AdminServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

public AdminServlet() {
super();
}
RequestDispatcher rd;

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws


ServletException, IOException {

HttpSession session = request.getSession();


session.getAttribute("adminId");

String action = request.getParameter("action");

if(action.equals("addCar")){
rd = request.getRequestDispatcher("AddCar.jsp");

}
else if(action.equals("carDetails")){
rd = request.getRequestDispatcher("CarDetails");

www.globsynfinishingschool.com
51

Document sign date :Jul 30, 2017


}
else if(action.equals("addDriver")){
rd = request.getRequestDispatcher("AddDriver.jsp");
}
else if(action.equals("driverDetails")){
rd = request.getRequestDispatcher("DriverDetailsRemove.jsp");
}
else if(action.equals("userData")){
rd = request.getRequestDispatcher("UserCheck.jsp");
}

rd.forward(request, response);

}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
// TODO Auto-generated method stub
doPost(request, response);
}

AddDriverServlet:
package com.globsyn.ecabproject.admin;

import java.io.IOException;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/AddDriver")
public class AddDriver extends HttpServlet {
private static final long serialVersionUID = 1L;
public AddDriver() {
super();
}
String message ;
String driverId;
String driverPassword;
java.sql.Connection con ;
java.sql.PreparedStatement st ;
public void init(){

ServletConfig config = getServletConfig();

String driver = config.getServletContext().getInitParameter("driver");


String url = config.getServletContext().getInitParameter("url");
String user = config.getServletContext().getInitParameter("username");
String passwd = config.getServletContext().getInitParameter("password");
try{
Class.forName(driver);

www.globsynfinishingschool.com
52

Document sign date :Jul 30, 2017


}catch(ClassNotFoundException e){
e.printStackTrace();
}
try{
con = DriverManager.getConnection(url,user,passwd);
}catch(SQLException e){
e.printStackTrace();
}
String insertsql = "insert into
driverdata(driver_name,driver_mob_no,driver_email,driver_password"
+
",user_address,driver_gender,driver_aadhar_card,driver_driving_license,car_no) "
+ "values(?,?,?,?,?,?,?,?,?);";
try{
st = con.prepareStatement(insertsql);
}catch(SQLException e){
e.printStackTrace();
}
}

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,


IOException {
doPost(request,response);
}

RequestDispatcher rd ;
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {

String driver_name=request.getParameter("drivername");
String driver_mob_no =request.getParameter("drivermobile");
String driver_email=request.getParameter("driveremail");
String driver_password=request.getParameter("driverpassword");
String user_address=request.getParameter("driveraddress");
String driver_gender=request.getParameter("gender");
String driver_aadhar_card=request.getParameter("driveraadharno");
String driver_driving_license=request.getParameter("driverlicenseno");
String car_no=request.getParameter("carNo");

try {
st.setString(1,driver_name);
st.setString(2,driver_mob_no);
st.setString(3,driver_email);
st.setString(4,driver_password);
st.setString(5,user_address);
st.setString(6,driver_gender);
st.setString(7,driver_aadhar_card);
st.setString(8,driver_driving_license);
st.setString(9,car_no);

st.execute();
message = "Driver Added and assigned car_no = "+car_no;
driverId = "Driver Id = "+driver_mob_no;
driverPassword = "Driver password = "+driver_password;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

www.globsynfinishingschool.com
53

Document sign date :Jul 30, 2017


rd = request.getRequestDispatcher("Administration.jsp");
request.setAttribute("key",message);
request.setAttribute("key1",driverId);
request.setAttribute("key2",driverPassword);
rd.forward(request, response);

public void destroy(){


try{
con.close();
st.close();
}catch(SQLException e){
e.printStackTrace();
}
}

BookingSevlet:
package com.globsyn.ecabproject.admin;

public class Booking {


private String booking_id;
private String driver_id;
private String user_id;
private String source;
private String destination;
private String fare;
private String date;
private String car_type;
public void Booking(){

public Booking(String booking_id, String driver_id, String user_id, String source, String destination, String
fare,
String date, String car_type) {
super();
this.booking_id = booking_id;
this.driver_id = driver_id;
this.user_id = user_id;
this.source = source;
this.destination = destination;
this.fare = fare;
this.date = date;
this.car_type = car_type;
}
public String getBooking_id() {

www.globsynfinishingschool.com
54

Document sign date :Jul 30, 2017


return booking_id;
}

public void setBooking_id(String booking_id) {


this.booking_id = booking_id;
}
public String getDriver_id() {
return driver_id;
}

public void setDriver_id(String driver_id) {


this.driver_id = driver_id;
}
public String getUser_id() {
return user_id;
}

public void setUser_id(String user_id) {


this.user_id = user_id;
}

public String getSource() {


return source;
}

public void setSource(String source) {


this.source = source;
}

public String getDestination() {


return destination;
}

public void setDestination(String destination) {


this.destination = destination;
}

public String getFare() {


return fare;
}

public void setFare(String fare) {


this.fare = fare;
}
public String getDate() {
return date;
}

public void setDate(String date) {


this.date = date;
}

public String getCar_type() {


return car_type;
}

public void setCar_type(String car_type) {


this.car_type = car_type;
}

www.globsynfinishingschool.com
55

Document sign date :Jul 30, 2017


}

DriverDetailServlet:
package com.globsyn.ecabproject.admin;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* Servlet implementation class driverDetail
*/

@WebServlet("/driverDetail")
public class driverDetail extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public driverDetail() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
// TODO Auto-generated method stub
response.getWriter().append("Served at: ").append(request.getContextPath());
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}

www.globsynfinishingschool.com
56

Document sign date :Jul 30, 2017


DriverDetailsRemoveServlet:
package com.globsyn.ecabproject.admin;

import java.io.IOException;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
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 javax.servlet.http.HttpSession;

import com.globsyn.ecabproject.driver.Driver;
import com.mysql.jdbc.ResultSetMetaData;

@WebServlet("/DriverDetailsRemove")
public class DriverDetailsRemove extends HttpServlet {
private static final long serialVersionUID = 1L;

public DriverDetailsRemove() {
super();
}

java.sql.Connection con;
java.sql.PreparedStatement st;
java.sql.PreparedStatement rst;

public void init() {

ServletConfig config = getServletConfig();

String driver = config.getServletContext().getInitParameter("driver");


String url = config.getServletContext().getInitParameter("url");
String user = config.getServletContext().getInitParameter("username");
String passwd = config.getServletContext().getInitParameter("password");

try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
try {
con = DriverManager.getConnection(url, user, passwd);
} catch (SQLException e) {
e.printStackTrace();
}
String query = "select * from driverdata where driver_mob_no = ?";
String remove = "delete from driverdata where driver_mob_no =?";
try {
st = ((java.sql.Connection) con).prepareStatement(query);
rst = ((java.sql.Connection) con).prepareStatement(remove);
} catch (SQLException e) {
e.printStackTrace();
}
}

www.globsynfinishingschool.com
57

Document sign date :Jul 30, 2017


RequestDispatcher rd;

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws


ServletException, IOException {
String message;
String mobile = request.getParameter("driverMobile");
String action = request.getParameter("action");
ResultSet rs ;

String driverid ="";


String drivername ="";
String drivermobile ="";
String driveremail ="";
String driverpassword ="";
String driveraddress ="";
String drivergender ="";
String driveraadhar ="";
String driverlicense ="";
String car_no ="";

int columncount;
if(action.equals("details"))
{
try {
st.setString(1,mobile);
rs = st.executeQuery();
if(rs.next()){
driverid = rs.getString(1);
drivername= rs.getString(2);
drivermobile= rs.getString(3);
driveremail= rs.getString(4);
driverpassword= rs.getString(5);
driveraddress= rs.getString(6);
drivergender= rs.getString(7);
driveraadhar= rs.getString(8);
driverlicense= rs.getString(9);
car_no= rs.getString(10);
}
rd = request.getRequestDispatcher("DriverDetails.jsp");
Driver driverdata = new
Driver(driverid,drivername,drivermobile,driveremail,driverpassword,driveraddress,drivergender,driveraadhar,driver
license,car_no);
HttpSession session = request.getSession();
session.setAttribute("driverdata",driverdata);
}catch (SQLException e) {
e.printStackTrace();
}

else if(action.equals("remove")){

try{
rst.setString(1,mobile);
rst.executeUpdate();
message = "Driver Deleted with Mobile No = "+mobile;
rd = request.getRequestDispatcher("DriverDetailsRemove.jsp");
request.setAttribute("key",message);
}catch(SQLException e){
e.printStackTrace();
}
}

www.globsynfinishingschool.com
58

Document sign date :Jul 30, 2017


rd.forward(request, response);

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,


IOException {
// TODO Auto-generated method stub
doPost(request, response);
}
public void destroy() {
try {
con.close();
st.close();
} catch (SQLException e) {
e.printStackTrace();
}
}

UserDetailServlet:
package com.globsyn.ecabproject.admin;

import java.io.IOException;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
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 javax.servlet.http.HttpSession;

import com.globsyn.ecabproject.user.User;
@WebServlet("/UserDetail")

public class UserDetail extends HttpServlet {


private static final long serialVersionUID = 1L;

public UserDetail() {
super();
// TODO Auto-generated constructor stub
}

java.sql.Connection con;
java.sql.PreparedStatement st;

public void init() {

ServletConfig config = getServletConfig();

String driver = config.getServletContext().getInitParameter("driver");


String url = config.getServletContext().getInitParameter("url");

www.globsynfinishingschool.com
59

Document sign date :Jul 30, 2017


String user = config.getServletContext().getInitParameter("username");
String passwd = config.getServletContext().getInitParameter("password");

try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}

try {
con = DriverManager.getConnection(url, user, passwd);
} catch (SQLException e) {
e.printStackTrace();
}
String query = "select * from userdata where user_mob_no = ?";
try {
st = ((java.sql.Connection) con).prepareStatement(query);
} catch (SQLException e) {
e.printStackTrace();
}
}

RequestDispatcher rd;

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws


ServletException, IOException {

String userMobile = request.getParameter("userMobile");

String message = "";

String userId = "" ;


String userName = "";
String gender ="";
String mobile ="";
String city ="";
String address="" ;
String email="" ;
String password ="";
String walletmoney ="";
String rides ="";
String dob ="";
ResultSet rs;
try {
st.setString(1, userMobile);
rs = st.executeQuery();
if (rs.next()) {
userId = rs.getString(1);
userName = rs.getString(2);
mobile = rs.getString(3);
email = rs.getString(4);
password = rs.getString(5);
address = rs.getString(6);
dob = rs.getString(7);
gender = rs.getString(8);
walletmoney = rs.getString(9);
rides = rs.getString(10);
city = "kolkata";
}
} catch (SQLException e) {
e.printStackTrace();
}

www.globsynfinishingschool.com
60

Document sign date :Jul 30, 2017


HttpSession session = request.getSession();
if(mobile==null){
message = "**invalid Driver mobile no**";
rd = request.getRequestDispatcher("UserCheck.jsp");
request.setAttribute("key",message);
}else{
User userdata = new User(userId, userName, mobile, email, password,
address,dob,gender,city,walletmoney,rides);
session.setAttribute("userdata",userdata);
rd = request.getRequestDispatcher("UserDetail.jsp");
}
rd.forward(request, response);

}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
// TODO Auto-generated method stub
doPost(request, response);
}

public void destroy() {


try {
con.close();
st.close();
} catch (SQLException e) {
e.printStackTrace();
}
}

www.globsynfinishingschool.com
61

Document sign date :Jul 30, 2017


Certificate

This is to certify that Mr. Sagnik Bhattacharyya of Academy of Technology, registration


number: 141690110070, has successfully completed a project on E-Cab Booking using JEE
under the guidance of Mr. Dayamay Halder.

------------------------------------------------------
Mr. Dayamay Halder
Globsyn Finishing School

www.globsynfinishingschool.com
62

Document sign date :Jul 30, 2017


Certificate

This is to certify that Mr. Somnath Karmakar of Government College of Engineering and
Leather Technology, registration number: 141120110038, has successfully completed a
project on E-Cab Booking using JEE under the guidance of Mr. Dayamay Halder.

------------------------------------------------------
Mr.Dayamay Halder
Globsyn Finishing School

www.globsynfinishingschool.com
63

Document sign date :Jul 30, 2017


Certificate

This is to certify that Ms. Deeksha Goyal of Institute of Engineering And Management,
registration number: 151040110248, has successfully completed a project on E-Cab
Booking using JEE under the guidance of Mr. Dayamay Halder.

------------------------------------------------------

Mr.Dayamay Halder
Globsyn Finishing School

www.globsynfinishingschool.com
64

Document sign date :Jul 30, 2017


Certificate

This is to certify that Mr. Subham Choudhary of Bengal College of Engineering And
Technology, registration number:141250110108, has successfully completed a project on
E-Cab Booking using JEE under the guidance of Mr. Dayamay Halder.

------------------------------------------------------
Mr.Dayamay Halder
Globsyn Finishing School

www.globsynfinishingschool.com
65

Document sign date :Jul 30, 2017


Certificate

This is to certify that Mr. Rajesh Gupta of Bengal College of Engineering And
Technology, registration number: 141250110075, has successfully completed a project on
E-Cab Booking using JEE under the guidance of Mr. Dayamay Halder.

------------------------------------------------------
Mr.Dayamay Halder
Globsyn Finishing School

www.globsynfinishingschool.com
66

Document sign date :Jul 30, 2017


Certificate

This is to certify that Mr. Shakir Ansari of Government College of Engineering And
Leather Technology, registration number: 141120110082, has successfully completed a
project on E-Cab Booking using JEE under the guidance of Mr. Dayamay Halder.

------------------------------------------------------
Mr.Dayamay Halder
Globsyn Finishing School

www.globsynfinishingschool.com
67

Document sign date :Jul 30, 2017


Certificate

This is to certify that Mr. Soumyojit Sasmal of Government College of Engineering And
Leather Technology, registration number: 151120120010, has successfully completed a
project on E-Cab Booking using JEE under the guidance of Mr. Dayamay Halder.

------------------------------------------------------
Mr.Dayamay Halder
Globsyn Finishing School

www.globsynfinishingschool.com
68

Document sign date :Jul 30, 2017


Certificate

This is to certify that Mr. Ashutosh Mahato of Government College of Engineering And
Leather Technology, registration number: 141120110008, has successfully completed a
project on E-Cab Booking using JEE under the guidance of Mr. Dayamay Halder.

------------------------------------------------------
Mr.Dayamay Halder
Globsyn Finishing School

www.globsynfinishingschool.com
69

Document sign date :Jul 30, 2017

You might also like