Skip to content

vaniii1/taxi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Taxi Service

A Java web application for managing a taxi service — including drivers, cars, and manufacturers. Built with plain Java Servlets and JSP, backed by a MySQL database.


Features 📝

  • Driver management — register, list, and delete drivers
  • Car management — add, list, and delete cars, assign drivers to cars
  • Manufacturer management — add, list, and delete manufacturers
  • Authentication — login/logout with session-based access control
  • Authorization filter — all routes are protected; unauthenticated users are redirected to login

Tech Stack

Layer Technology
Language Java 17
Web layer Jakarta Servlet API 5.0, JSP, JSTL 1.2
Database MySQL 8
DB driver mysql-connector-java 8.0.22
Build tool Maven (packaged as .war)
Server Any Jakarta EE–compatible servlet container (e.g. Tomcat 10+)

Project Structure

taxi/
├── controller/
│   ├── IndexController
│   ├── authentication/    # LoginController, LogoutController
│   ├── car/               # Add, Delete, GetAll, AddDriverToCar
│   ├── driver/            # Add, Delete, GetAll, GetMyCurrentCars
│   └── manufacturer/      # Add, Delete, GetAll
├── dao/
│   ├── GenericDao
│   ├── CarDao / CarDaoImpl
│   ├── DriverDao / DriverDaoImpl
│   └── ManufacturerDao / ManufacturerDaoImpl
├── service/
│   ├── CarService / CarServiceImpl
│   ├── DriverService / DriverServiceImpl
│   ├── ManufacturerService / ManufacturerServiceImpl
│   └── AuthenticationService / AuthenticationServiceImpl
├── model/
│   ├── Car
│   ├── Driver
│   └── Manufacturer
├── util/
│   └── ConnectionUtil       # JDBC connection factory
├── lib/
│   ├── @Dao, @Service, @Inject  # Custom DI annotations
│   └── Injector             # Simple dependency injector
├── web/filter/
│   └── AuthenticationFilter
└── exception/
    ├── DataProcessingException
    └── AuthenticationException

Database Schema

The application uses a MySQL schema named taxi-db. Initialize it by running the provided SQL script:

WEB-INF/classes/init_db.sql

Tables

  • driversid, name, license_number, login, password, is_deleted
  • manufacturersid, name, country, is_deleted
  • carsid, model, manufacturer_id, is_deleted
  • cars_drivers — join table linking cars and drivers (car_id, driver_id)

Soft deletes are used throughout (is_deleted flag).

Entity Relation Diagram

erd


Configuration

Database connection is configured in ConnectionUtil. The connection URL, driver class, and credentials should be set via environment variables or by editing the class directly before building:

JDBC URL:   jdbc:mysql://<host>:3306/taxi
Driver:     com.mysql.cj.jdbc.Driver

URL Routes

Method URL Description
GET/POST / or /index Home page
GET/POST /login Login
GET /logout Logout
GET/POST /register Register a new driver
GET/POST /drivers/add Add a driver
GET /drivers List all drivers
GET/POST /drivers/delete Delete a driver
GET /driver/cars View cars assigned to the current driver
GET/POST /cars/add Add a car
GET /cars List all cars
GET/POST /cars/delete Delete a car
GET/POST /cars/drivers/add Assign a driver to a car
GET/POST /manufacturers/add Add a manufacturer
GET /manufacturers List all manufacturers
GET/POST /manufacturers/delete Delete a manufacturer

All routes (except /login and /register) require an authenticated session via AuthenticationFilter.


Building & Deployment

Prerequisites

  • JDK 17+
  • Maven 3.6+
  • MySQL 8 instance
  • Tomcat 10+ (or any Jakarta EE 5.0-compatible servlet container)

Build

mvn clean package

The WAR file will be generated at:

target/taxi-1.0-SNAPSHOT.war

Deploy 🚀

If you decided to start up this project, you need to obtain at least java 17 and MySQL. The file with SQL code (package named "resources" on the same level with "java" package) you can compile in MySQL environment. When your DB is ready for use you need to change some fields in ConnectionUtil.class:

private static final String URL = "YOUR URL";
private static final String USERNAME = "YOUR USERNAME";
private static final String PASSWORD = "YOUR PASSWORD";
private static final String JDBC_DRIVER = "YOUR JDBC DRIVER";

Tomcat configuration:

To add tomcat configuration you need to choose: Run -> Edit Configurations -> click the plus in the top left corner -> search for Tomcat Server -> local -> configure... (in the right window that appears) -> insert the path where your tomcat is installed -> OK -> Fix (in the right bottom corner) -> choose 'war exploded artifact' -> deployment (on the top bar) -> change application context to "/".

I use tomcat 10 on this application, but if you want to use tomcat 9 you have to change jakarta to javax dependency. In addition, you will have to change some class imports which contains `jakarta`. Then, you need to rebuild your project (Ctrl + F9).

<dependency>                                                            
        <groupId>jakarta.servlet</groupId>
        <artifactId>jakarta.servlet-api</artifactId>
        <version>5.0.0</version>
        <scope>provided</scope>
</dependency> 
<dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>4.0.1</version>
        <scope>provided</scope>
</dependency>

Project Structure 📂##

Taxi Service has an N-Tier Architecture

  1. Controller layer - responsible for communication between client and server, displays .jsp pages.
  2. DAO layer - responsible for CRUD operations on the database.
  3. Util layer - provides a connection to the database.
  4. Service layer - responsible for the business logic of the application.
  5. Filter layer - responsible for filtering requests (client) and responses (server).

Dependency Injection

The project includes a lightweight custom DI framework (taxi.lib):

  • @Dao — marks DAO implementation classes
  • @Service — marks Service implementation classes
  • @Inject — marks fields to be injected
  • Injector — resolves and injects dependencies at runtime via reflection

Screenshot Examples

Menu

Menu

Registration

Registration

Login

Login

Display My Cars

My Cars

Notes

  • Passwords are stored as plain text. For any real deployment, add proper hashing (e.g. BCrypt).
  • The project uses Checkstyle for code style enforcement during the compile phase (checkstyle.xml must be present in the project root to build from source).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors