Skip to content

YehorLiannyk/cinema-webapp-java-servlet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cinema Web Application with Java Servlet API 🎥

The Final task of the EPAM external course

This project is a web application implementation of a cinema WebApp using Java Servlet API. In a nutshell, there are movies and their sessions, which you can search for using filters, then select needed one, choose seats and buy tickets. But first, you should sign up/in. After purchase, you can find your tickets on the user ticket page and download them in PDF format. Admin can add/remove new movies and movie sessions as well.

Content 📑

Introduction 👋

The system is an online showcase of a single-screen cinema.

There are 3 roles:
  • Unauthorized user (guest)
  • Authorized user (customer)
  • Administrator
The system includes:
  • Schedule current films for a week from 9:00 a.m. to 10:00 p.m. (beginning of the last film).
  • An unauthorized user can see the session schedule, and available seats for current movies, and has the opportunity to sign up. The user should be able to sort the movie sessions' schedule by
    1. the movie name;
    2. the number of available seats;
    3. the date/time of the session (by default); as well as filter available movies (due to empty seats) in the schedule.
  • A signed-up user has to be able to purchase a ticket for the selected movie session.
  • The administrator can add a new movie to the schedule, cancel the movie, and review the attendance of the hall.

Technologies 💻

  • Back end: Java, Java 8, Jakarta EE, Jakarta Servlet, Servlet Filters; JDBC, SQL; JUnit, Mockito; Log4j2 SLF4J; Google reCaptcha; iText PDF.
  • Front end: JSP, JSTL; CSS, Bootstrap 4.
  • Database Management System: MySQL

How to install/run ⚙️

  1. Fork this repository.
  2. Clone the repository on your machine
  3. Make sure you have at least v.10.0.26 of Apache Tomcat Server (may be downloaded from this link) and MySQL Server at least v.8.0.29
  4. Using MySQL Workbench (or another tool), import the database schema and data dump from file cinema-webapp-java/src/sql/cinema_db_{DATE}.sql. IMPORTANT: if the dates and times of the sessions are outdated they will no longer be shown on the session page, so in such case, you need to change the dates of the sessions manually.
  5. If needed, change the Database name and credentials in file cinema-webapp-java/src/main/resources/db.properties
  6. Also be aware of the log files will be saved to E:\\logs folder, so you can change the path in file cinema-webapp-java-servlet/src/main/resources/log4j.properties
  7. Add Tomcat Configuration and Run the app. How to run the project right after downloading:
  8. After running, point your browser to http://localhost:8090/cinema-webapp-java-servlet/.

What was implemented 🔧

  • Designed and built the application and database scheme
  • Used patterns such as MVC, Front Controller, Factory Method, Singleton, Abstract Factory, DAO, PRG (Post/Redirect/Get)
  • Implemented Database ConnectionPool with Apache Commons DBCP BasicDataSource using Singleton pattern
  • Implemented logging in Console and Files using Log4j2 SLF4J
  • Implemented authentication and authorization systems
  • Implemented user permissions and page access using Servlet Filter
  • Implemented back-end data validation (partially using front-end validation with HTML)
  • Added Google reCaptcha validation during user sign up
  • Implemented password encryption using a salt value for hashing
  • Implemented JDBC transactions
  • Implemented pagination and schedule filtering/sorting at the back-end side using SQL
  • Implemented Ukrainian and English localizations using ResourceBundle and JSTL
  • Implemented Cookies support for localization and user session
  • Added PDF ticket creation using iTextPDF
  • Implemented exception handling mechanism with the custom class handler redirecting to the error page
  • Covered the application with tests using JUnit4 and Mockito
  • Created custom JSP tag files for header, menu, and footer
  • Created custom JSP tags for movie genres enumeration and pagination block

Entity–relationship model of the database 🚩

There are entities: Film, Genre, Session, Seat, Ticket, User, and its Role.

View of the database schema

Demonstration 📺

Firstly, the site is multilingual: Ukrainian and English versions. Everything has been translated, except errors and database data. The user lang option is stored in a cookie file.

Multilang demo

This is the main page where you can see a list of current films. Films list is paginated just like sessions and user tickets are.

Main page demo

The next stop is the Schedule page, where you can see a session schedule and choose which one to buy. Sorting and filtering options help you with that, which are implemented using SQL queries.

Schedule page demo

But only authorized users can buy a ticket, so you have to sign up first. There are backend and frontend (partly) validations, and Google reCaptcha is also used. All fields, except phone number, are required.

Sign up demo

If Google reCaptcha wasn't checked - the server return error.

Google reCaptcha demo

Let's try to log out and sign in again. Cookie files save the user role and user id what lets the user stay signed in.

Login and logout demo

After choosing a session, you pick wanted remained seats and then confirm your purchase.

Buy ticket demo

You also may download the ticket in PDF format. (Sending via email wasn't implemented)

Download PDF ticket demo

Tests 🔨

Tests were written using the Mockito and JUnit frameworks. More than 50% of code lines are covered.

test coverage

Author 🙋‍♂️

You can get in touch with me on my LinkedIn Profile: LinkedIn Link

You can also follow my GitHub Profile to stay updated about my latest projects: GitHub Follow

If you liked the repo then kindly support it by giving it a star ⭐