BCSP 064 1
BCSP 064 1
BCSP 064 1
Submitted By:
1
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
Table of Content
Introduction 3
Objective 4
Project Category 5
Design of Project 8
Data Flow Diagrams 8
Level 1 ( User ) 9
Level 2 ( User ) 10
Data Structure 12
Testing Process 17
GANTT Chart 18
Validation Check 19
Limitations of Project 20
Bibliography 22
2
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
Introduction
Online Café Hub is a website where users can come to spend
time listening to some random music or a video. They can chat
with strangers. They can also order something from the menu
integrated in the website.
The users can order food through online food delivery services
like Zepto / Zomato / Swiggy. An additional menu will be
provided for users who want to order food from “CAFEDO”, a
local café in my neighbourhood that I want to bring attention
to through this project.
3
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
Objective
This project tries to attain the following objectives:
❖ Provide an aesthetic place to meet new people virtually.
❖ Bring people closer.
❖ Provide a safe virtual space.
❖ Provide a relaxing environment.
❖ Protect people from rude users by banning them by
implementing a report system.
4
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
Project Category
• This project is based on the three-tier architecture, where
the application is divided into three layers:
❖ User Layer:
Provides the user with website interface and access to website
resources. (JSP)
❖ Business Layer:
Implements the business logic on how the user will access the
website resource and chat with other users. (JS and Servlet)
❖ Physical Layer:
Provides handling and validation of data in the database and
accepting client connection, in the backend. (Java)
5
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
6
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
7
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
Design of Project
Data Flow Diagrams
8
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
Level 1 ( User )
9
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
Level 2 ( User )
10
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
11
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
Data Structure
12
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
13
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
1. User Login
2. User Registration
3. Field Validation
4. User Management
5. Token Management
6. Table Management
7. Feedback Management
8. Report Management
14
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
User – Can access the website and sit at a table to chat with others,
order food from the menu, report other users or give feedback.
Staff – Can review the reports and feedback and take appropriate
actions.
15
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
16
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
Testing Process
Alpha testing will be done at the developer’s site and beta test
will begin once the project has been deployed for testing on
the server.
17
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
GANTT Chart
Week 1 to Week 4:
Week 5 to Week 8:
18
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
Validation Check
❖User Id, Admin Id, Staff Id, Report Id, Feedback Id, Dates
are automatically generated.
19
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
Limitations of Project
20
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
21
Enrolment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Synopsis for BCSP-064 Online Café Hub
Bibliography
Websites:
• www.javatpoint.com
• www.tutorialspoint.com
• IGNOU Blocks
22
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
Project Title
2
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
Table of Contents
3
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
4
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
5
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
Table of Figures
Figure 1 – Context Level (Level 0) Data Flow Diagram of Online Café Hub............28
Figure 2 – Data Flow Diagram (Level 1) of Online Café Hub ...................................29
Figure 3 – Data Flow Diagram (Level 2) of Online Café Hub ...................................30
Figure 4 – Entity Relationship Diagram for Online Café Hub ..................................31
Figure 5 – Use Case Diagram of Online Café Hub ....................................................32
Figure 6 – GANTT Chart (Week 1 – Week 4) .......................................................... 33
Figure 7 – GANTT Chart (Week 5 – Week 7) .......................................................... 33
Figure 8 – GANTT Chart (Week 8 – Week 9) .......................................................... 33
Figure 9 – Interaction Between Different Components of Online Café Hub ..............43
Figure 10 – Home Page (View 1) ............................................................................ 210
Figure 11 – Home Page (View 2) ............................................................................ 210
Figure 12 – Home Page (View 3)............................................................................. 211
Figure 13 – About Page (View 1) ............................................................................ 211
Figure 14 –About Page (View 2) ............................................................................. 212
Figure 15 – About Page (View 3) ............................................................................ 212
Figure 16 – About Page (View 4) ............................................................................ 213
Figure 17 – Menu Page (View 1) ............................................................................. 213
Figure 18 – Menu Page (View 2) ............................................................................. 214
Figure 19 – Menu Page (View 3) ............................................................................. 214
Figure 20 – Menu Page (View 4) ............................................................................. 215
Figure 21 – Login Page............................................................................................ 215
Figure 22 – Login Page (Field Validation) .............................................................. 216
Figure 23 – Login Page (Valid Registration) ........................................................... 216
Figure 24 – Login Page (Invalid Registration) ........................................................ 217
Figure 25 – Login Page (Invalid Login) ................................................................... 217
Figure 26 – Cafe Page ............................................................................................. 218
Figure 27 – Chatroom Page ..................................................................................... 218
Figure 28 – Report Page.......................................................................................... 219
Figure 29 – Report Page (Invalid Values) ............................................................... 219
Figure 30 – Report Page (Viewing a long report reason) ........................................ 220
Figure 31 – Feedback Form ..................................................................................... 220
Figure 32 – My Account Page (View 1) .................................................................. 221
Figure 33 – My Account Page (View 2) .................................................................. 221
Figure 34 – Token Management Page ..................................................................... 222
Figure 35 – Table Management Page ...................................................................... 222
6
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
7
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
1. Introduction
1.1 Background Information
comfortable space to engage with others, especially strangers, can often be a challenge.
In an effort to bridge this gap, the concept of the "Online Cafe Hub" was born.
The Online Cafe Hub aims to provide a unique online platform that serves as a virtual
space for individuals to engage in friendly conversations with strangers while also
facilitating the ordering of food from a local cafe. This project not only promotes the
local cafe but also creates a welcoming environment where people can come together
At its core, the Online Cafe Hub seeks to recreate the warm and inviting atmosphere
application with the convenience of online food ordering, the project strives to offer a
comprehensive experience that caters to the needs of both cafe enthusiasts and those
8
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
By leveraging the power of technology and the growing demand for virtual
socialization, the Online Cafe Hub aims to revolutionize the way people connect and
experience cafes. Whether it's a desire for stimulating conversations, a craving for
delicious food, or simply a need for social interaction, this project strives to fulfil these
Through the creation of the Online Cafe Hub, the vision is to build a vibrant online
fosters a sense of togetherness, all within the virtual walls of a cafe-like environment.
9
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
T
HE "Online Cafe Hub" is a website that allows you to have conversations with
new people while also ordering food from a local cafe called "CAFEDO". When
you visit the website, you can create an account or log in with your existing details.
Once logged in, you can explore the menu of CAFEDO and choose the items you want
to order.
To make things more interesting, you can join virtual tables where you can chat with
other users just like you would in a real cafe. If you come across someone who is
behaving offensively, you can report them, and the website will take appropriate action
If you have any feedback about your experience, the food, or anything else, you can
submit it to help improve the website and the cafe's services. Additionally, you have
the option to update your account details like your username or password as needed.
In summary, the Online Cafe Hub is a place where you can talk to new people, order
food from CAFEDO, report offensive behaviour, give feedback, and manage your
10
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
account information. It aims to create a safe and enjoyable online space that promotes
11
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• User Layer: Provides the user with website interface and access to website
resources. (JSP)
• Business Layer: Implements the business logic on how the user will access the
website resource and chat with other users. (JS and Servlet)
• Physical Layer: Provides handling and validation of data in the database and
• Extra load on the server as all the calculations are done on the server instead
12
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• Java is perfect for developing large web applications because of its ability to
• Rich APIs available for free. APIs for networking, I/O, XML parsing,
at the same time. This provides a faster response time to users, less issues,
• Java is easily scalable. Java can adapt to the needs of the web application. To
improve the response time and the performance of the web app, minimal and
• Data categorization. DBA can easily categorize and store data in an RDB
that can then be queried and filtered to extract information for reports.
13
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
procedures.
• Ease of Use. Complex queries are easy to carry out with SQL.
specific users.
14
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
T
HE "Online Cafe Hub" project aims to create a comprehensive website that
strangers while also allowing them to order food from a local cafe. The key elements
of the project scope include integrating a chat module and food ordering system into
Users will have the opportunity to initiate and participate in conversations with
strangers through the chat module. Simultaneously, they can explore the menu of the
local cafe and place their desired food orders. This integration of chatting and food
ordering functionalities will create a unique and immersive experience for users,
combining the social aspect of conversations with the convenience of online food
ordering.
The website will also incorporate features such as reporting, feedback, and user
credential management. Users will have the ability to report offensive behaviour or
users to share their experiences, provide suggestions, and offer feedback on the cafe's
15
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
offerings and the overall functionality of the website. Furthermore, users will have the
flexibility to update their account credentials, including their username, password, and
A user-friendly interface will be designed to enhance the overall user experience. Clear
instructions and user guidance will be implemented to facilitate easy navigation and
interaction with the website. The layout and organization of the website will be logical
and intuitive, ensuring that features and functionalities are easily accessible and user-
friendly.
Considering future growth and increasing user demands, the project will be developed
To ensure the security and privacy of user information, robust security measures will
utilized to safeguard sensitive user credentials. Best practices for data security will be
16
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
software tools and environment used during the development of the project.
engineering concepts used during the analysis phase of the project. It includes
engineering concepts used during the design phase of the project. It includes
17
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
Design.
• Chapter 6: Program Code - This chapter presents the program code for the
• Chapter 7: Testing - This chapter describes the test case designs used for
development phase.
18
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• Chapter 12: Bibliography - This chapter provides a list of all the sources
19
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
2. Objectives
system.
awarded to users who visit the site) to skip videos/music, and get discount on
CAFEDO menu.
20
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
21
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
T HE following tools and technologies were used in the development of the Online
• Eclipse IDE for Enterprise Java and Web Developers: This is a powerful
software tool designed for developers working on Java and web-based projects.
• JSP: It is a server-side scripting language that combines Java code with HTML
or XML mark-up to generate dynamic content. JSP pages are compiled into
• HTML: This is the standard mark-up language used to create web pages. It is
22
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• CSS: This is a stylesheet language that is used to describe the presentation and
of rules that define how elements should be displayed, including properties like
layout, colours, fonts, and animations, allowing for enhanced design and layout
(RDBMS) widely used for storing and managing structured data. It provides a
robust and scalable platform for creating, organizing, and accessing databases.
MySQL supports SQL (Structured Query Language) and offers features such as
23
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• Windows 10: This is the most used version of the Windows operating system,
• Google Chrome: Google Chrome's DevTools are known for their extensive
and network analysis tools. Chrome's unique features like Device Mode for
10 and provides a rich set of developer tools. Its unique features include the
Emulation Mode, which enables testing across different devices and browsers,
and the built-in WebDriver support for automated testing. Edge is great for
ecosystem.
24
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
4. Analysis Document
4.1 Requirement Analysis
O
UR primary objective is to provide a web-based platform where users can login
or register and have access to the chatting and other feature of the website. To
• The system should allow users to register with their personal details, including
• The system should transfer sensitive user data over a secure connection to
• The system should store sensitive user data like password in encrypted form.
• The system should provide users the option to report other users who behave
inappropriately.
• The system should provide a feedback form where users can give suggestions
• The system should provide a chatroom when a table with empty seats is clicked
by a user.
25
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• The system should provide various management services to admin / staff like
Feedback View.
• The system should be accessible from a variety of devices and web browsers.
• The system should display appropriate and absolute Error or Success messages
26
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
cycle, as it lays the foundation for the entire project. The following techniques
were used to gather requirements for the Online Café Hub project:
• Interviews: Interviews with different age group people, owners and workers of
cafes, professors and project guide to understand their expectations and needs.
• Focus Groups: Focus groups were conducted with selected group of people of
• Online Surveys: Forums were created on Quora and Reddit to gather needs
and fellow students to generate ideas for potential features, functionalities and
design of the platform based on the insights gathered from Interviews, Focus
27
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
Figure 1 – Context Level (Level 0) Data Flow Diagram of Online Café Hub
28
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
29
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
30
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
31
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
32
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
33
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
Sr. No. Attribute Name Data Type Data Format Constraint Description
1 u_id int integer primary Unique ID of user
key
2 u_name varchar string not null Name of user
3 u_email varchar string not null Email of user
4 u_pass varchar string not null Password of user
5 u_phn varchar string not null Phone Number of
user
6 u_tokens int integer default 10 User tokens
7 banned varchar string default Whether user is
false banned or not
8 violations int integer default 0 User violations
Sr. No. Attribute Name Data Type Data Format Constraint Description
1 a_id int integer primary Unique ID of
key admin
2 a_name varchar string not null Name of admin
3 a_email varchar string not null Email of admin
4 a_pass varchar string not null Password of admin
5 a_phn varchar string not null Phone Number of
admin
6 a_privilege int integer default 0 Admin clearance
8 violations int integer default 0 Staff violations
34
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
Sr. No. Attribute Name Data Type Data Format Constraint Description
1 t_id int integer primary Unique ID of a
key table
2 chairs int integer not null Total no. of chairs
in a table
3 available int integer default 0 Available chairs
4 inuse int integer default 0 Chairs in use
Sr. No. Attribute Name Data Type Data Format Constraint Description
1 r_id int integer primary Unique ID of a
key report
2 r_date datetime yyyy-mm-dd default Date & time the
hh:mm:ss current report was made
timestamp
3 offender_id int integer foreign key Unique ID of
offender from users
table
4 reporter_id int integer primary Unique ID of
key reporter from users
table
5 reason varchar string not null Reason for making
the report
6 action varchar string default Action taken by
“pending” admin
35
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
Sr. No. Attribute Name Data Type Data Format Constraint Description
1 f_id int integer primary Unique ID of
key feedback
2 u_id int integer foreign key Unique ID of user
3 message varchar string not null Feedback message
4 f_date datetime yyyy-mm-dd default Date & time of
hh:mm:ss current giving the feedback
timestamp
The rest of the Data Dictionaries are for tables that log certain actions:
Sr. No. Attribute Name Data Type Data Format Constraint Description
1 id int integer primary Unique ID of log
key
2 a_id int integer foreign key Unique ID of
admin making the
action
3 u_id int integer foreign key Unique ID of user
being acted against
4 action varchar string not null Whether user was
banned or
unbanned
5 reason varchar string not null Reason for the
action taken
6 date datetime yyyy-mm-dd default Date & time when
hh:mm:ss current the action was
timestamp taken
36
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
Sr. No. Attribute Name Data Type Data Format Constraint Description
1 id int integer primary Unique ID of log
key
2 a_id int integer foreign key Unique ID of
admin making the
action
3 u_id int integer foreign key Unique ID of user
being acted against
4 tokens int integer not null No. of tokens taken
or given
5 reason varchar string not null Reason for the
action
6 date datetime yyyy-mm-dd default Date & time when
hh:mm:ss current the action was
timestamp taken
7 action varchar string not null Whether tokens
were added or
removed
Sr. No. Attribute Name Data Type Data Format Constraint Description
1 id int integer primary Unique ID of log
key
2 a_id int integer foreign key Unique ID of
admin making the
action
3 t_id int integer foreign key Unique ID of table
being acted upon
4 action varchar string not null Whether chairs are
being added or
removed
5 chairs int integer not null No. of chairs
6 date datetime yyyy-mm-dd default Date & time when
hh:mm:ss current the action was
timestamp taken
37
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
Sr. No. Attribute Name Data Type Data Format Constraint Description
1 id int integer primary Unique ID of log
key
2 a_id int integer foreign key Unique ID of
admin doing
unauthorized work
3 page varchar string not null Where the admin
did unauthorized
work
4 date datetime yyyy-mm-dd default Date & time when
hh:mm:ss current the unauthorized
timestamp work was done
38
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
5. Design Document
D ESIGN phase of the Online Café Hub project involves creating a blueprint for
the website's layout, navigation, and functionality. This phase builds on the
analysis phase and incorporates all the requirements and specifications gathered
In this phase, we will create detailed design specifications for the various modules of
the website. This will include creating wireframes, user interfaces, and prototypes that
The design phase is critical because it sets the foundation for the entire project. A
well-designed website will not only meet the functional requirements but also provide
an excellent user experience to the website's users. Therefore, it is essential to get the
39
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
In the following sections of this document, we will detail the design specifications for
each module of the Online Café Hub website. We will also describe how these modules
40
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
S
YSTEM architecture of Online Café Hub describes the overall design of the
system, including its components and their interactions. The system is designed
as a web application, which provides an online platform for users to come together and
enjoy the comfort of togetherness while being miles apart, getting to socialize and enjoy
• User Interface: The user interface is the front-end of the system, which is
interact with the system and perform various tasks, such as joining tables to
chat, ordering food, browsing menu, reporting a user and giving feedback.
• Server: The server is the back-end of the system, which handles the processing
and storage of data. It receives requests from the user interface, performs the
necessary computations, and returns the results to the user interface. It is also
responsible for routing the requests to appropriate web pages. It also stores and
41
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• Database: The database is the central repository of the system, which stores
all the data related to the users, tables, reports, feedbacks, logs. It is used by
the server to store and retrieve data as per the requirements of the user
interface.
42
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
The user interface sends requests to the server, which processes the requests and sends
back the results to the user interface. The server communicates with the database to
store and retrieve data as per the requests received from the user interface.
43
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
specific set of tasks. This modular approach enhances maintainability, scalability, and
• Authentication: This module will allow users to register and login to Online
Café Hub website. This module will be responsible for user data security as well.
This module will incorporate user detail updating like changing email, phone
number and password. Only after the user is logged in will they be able to
access the café area where they can chat and use the other features of the café.
• Reporting: This module will allow users to report other users acting offensive,
the users will be able to see the reports they have made and the action taken
on those reports. This module will allow admin and staff to review the reports
• Feedback: This module will allow users to give their feedback about the
website and what improvements, if any, can be made. Admin and Staff will be
44
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• Chatting: This module will be responsible for handling user chat sessions. The
• Contact: This module will enable all the users to contact the site admin via
emailing service. This module will incorporate the mail server aspect of the
• Management: This module will allow admin and staff to manage the system
adding / removing user tokens with reason, and banning / unbanning users
with reason will be provided by this module. It will also be responsible for
making logs about the actions taken by admin and staff and recording them
onto proper tables like unauthorized, table log, user ban log, and token log.
E NSURING data integrity is crucial for the proper functioning and reliability of
the Online Café Hub system. The system employs various data integrity
measures and constraints to maintain the accuracy, consistency, and validity of the
45
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
data stored in the database. The following data integrity and constraints are
implemented:
• Entity Integrity: Each primary key in the database is unique and not null,
referential integrity among related tables. For example, the “u_id” attribute in
attribute in users table, ensuring the only registered users are associated with
predefined data types and constraints. For example, the “u_email” attribute in
the “users” table is validated to ensure it follows a valid email format, and the
“chairs” attribute in the “tables” table has a constraint that it cannot be negative
uniqueness within the table. For instance, the “u_email”, “u_phn”, and
46
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• Check Constraints: Check constraints are used to validate the values entered
“banned” attribute in the “users” table has a check constraint to ensure it can
only have a value of “false” or “true”, indicating whether the user is banned or
not.
default value when no explicit value is specified during record insertion. For
These data integrity measures and constraints help to maintain the consistency and
validity of the data stored in the database. They prevent data inconsistencies, ensure
accurate relationships between tables, and enforce data validation rules. By adhering
to these constraints, the Online Café Hub system can operate reliably and provide
47
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
to ensure that the database is designed correctly and efficiently. The database
design will help in organizing the data in a structured and systematic manner. The
following things were taken into consideration during the implementation of database
We have used the Entity Relationship (ER) modelling technique to design the database
for Online Café Hub. ER modelling is used to design the structure and relationships
48
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
Each entity in the database has a unique set of columns that are defined based on the
requirements of the website. The relationships between the tables are also defined,
The database has been normalized to ensure that the data is organized efficiently
and without redundancy. We have used the third normal form (3NF) to ensure that
49
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
The database has been normalized to ensure that the data is organized efficiently
and without redundancy. We have used the third normal form (3NF) to ensure that
Overall, the database design for the Online Café Hub website has been created keeping
in mind the requirements of the website and the best practices for database design.
The design ensures that the data is organized efficiently, and the performance of the
system is optimized.
50
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
L
OGIC design of procedures explains how the different modules of the Online
Café Hub interact with each other to give the optimal satisfaction to the user
as well as providing security. The following modules / procedures were made in the
• When the user clicks on the “Login” or “Register” button on the Home Page,
they are presented with the Login Page where they have two forms, registration
and login.
• If the user is registering then they have to provide their credentials (name,
email, phone number, and password) and submit the form by clicking on the
“Register” button.
• The website will then validate the user’s input on the client-side and if it is
valid, a new user would be created and redirect them to the Login Page.
• If the user is logging in, they have to provide their email and password and
51
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• The website will then validate the user’s input on the client-side and if it is
valid, a session will be created for the user and they will be redirected to the
Café Page.
• When an admin or staff logs in, they will be presented with the Token
Management Page.
• They will be presented with a form where the user id, tokens, and reason input
• When submitted, the form is validated on the client-side browser. If the form
displayed on the client-side once the server is done processing the data.
• This module can be submitted only by Admins (privilege 1). If a Staff (privilege
table.
52
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• The admin can navigate to the Table Management page by clicking on the
• They will be presented with a form where the chair id, and chairs input fields
and three buttons, namely, “Add Table”, “Update Table” and “Remove Table”
will be provided. A table with all the attributes and tuples of the table “tables”
• When submitted, the form is validated on the client-side browser. If the form
displayed on the client-side once the server is done processing the data.
• A log is created in the tablelog table if the database action was a success.
• The admin can navigate to the User Management page by clicking on the
53
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• They will be presented with a form where the user id, and reason input fields
and two buttons, namely, “Ban User”, and “Unban User” will be provided. A
table with all the attributes except “u_pass” and tuples of the table “users” will
also be provided.
• When submitted, the form is validated on the client-side browser. If the form
displayed on the client-side once the server is done processing the data.
• This module can be submitted only by Admins (privilege 1). If a Staff (privilege
table. If Admin is making the action, a log in the “userbanlog” table is created.
• The admin can navigate to the Reports page by clicking on the appropriate
• They will be presented with all the attributes and tuples from the “reports”
table.
54
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• To take any action, they can navigate to the User Management Page.
• The admin can navigate to the Feedbacks page by clicking on the appropriate
• They will be presented with all the attributes and tuples from the “feedback”
table.
• Users can navigate to the Café Page and join a table to create a session with
• Once inside the Chat window, users can leave the chatroom by simply clicking
• Users can also order food by clicking on the two services available beside the
“Leave” button.
55
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• Users can navigate to the Report page by clicking on the appropriate tag / link
on the navbar.
• The user is presented with a form containing the input fields user id and reason.
• When submitted, the form is validated on the client-side browser. If the form
displayed on the client-side once the server is done processing the data.
• Users can navigate to the Feedback page by clicking on the appropriate tag /
• The user is presented with a form containing the input field message.
56
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• When submitted, the form is validated on the client-side browser. If the form
displayed on the client-side once the server is done processing the data.
• The user can navigate to the My Account page from the navbar.
• They will be presented with their details like id, name, email, phone, tokens,
and violations. They will also be presented with three short forms.
• The first form contains the input fields new email and password.
• The second form contains the input fields new phone number and password.
• The third form contains the input fields new password and old password.
• When a user clicks on a particular button associated with a certain form, the
fields are validated on the client-side and then sent to the server-side. After the
client / user.
57
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• Any user, whether registered or not can use this form to send emails to the site
admin.
• They will be presented with a form containing input fields email, subject and
message.
• When submitted, the form is validated on the client-side and then sent to the
server-side where a smpt mail server will deliver the message to the site admin.
• The user / admin / staff can click on the logout button on the navbar or close
58
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
6. Program Code
6.1 Introduction to The Implementation Phase
The implementation phase of Online Café Hub marks the transition from the design
and planning stages to the actual development of the website. This phase involves
translating the design specifications and requirements into functional code using the
selected programming language, JSP, and Java, along with HTML, CSS, and
JavaScript.
The implementation phase also involves error handling and exception management to
ensure robustness and reliability of the website. Proper error messages, logging
mechanisms, and input validation techniques are employed to enhance the user
phase includes integration with the MySQL database management system. The code
59
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
interacts with the database to retrieve and store data, utilizing appropriate SQL
Throughout the implementation phase, the development team conducts regular testing
and debugging to identify and rectify any issues or inconsistencies in the code. This
iterative process helps in ensuring the quality and stability of the implemented features
and functionalities.
60
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
61
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
62
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
63
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
SCRIPTS
“my_alert.js”. These utility functions are used heavily to ensure form input validations
formValidation.js:
This JavaScript code defines a function called validateFields that takes two
parameters: ele (an array of element IDs) and formId (the ID of a form).
The purpose of this function is to validate the fields in a form before submitting it. It
performs various checks on different types of input fields, such as text, password, email,
The ele array is passed to the getElements function, which retrieves the corresponding
The code then iterates through each element and performs specific validation checks
based on its type. For text and password fields, it checks if they have a non-zero length
and if they meet certain length requirements. For email fields, it checks if they have a
valid email format and do not exceed a certain length. For number fields with the ID
64
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
"phn", it checks if they are a valid phone number. For textarea fields, it checks if they
If any validation error is found, it either shows an error message using the myAlert
function or adds a red border to the respective field using the showError function. The
If all fields pass the validation checks, the form with the specified formId is submitted
by calling document.getElementById(formId).submit().
if (
ele[i].type === "email" &&
(!ele[i].value.length || !validEmail(ele[i].value))
)
return showError(ele[i]);
if (ele[i].type === "email" && ele[i].value.length > 40)
return myAlert("Error: Email should not exceed 40 characters.");
if (
ele[i].type === "number" &&
65
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
if (
ele[i].type === "textarea" &&
!(ele[i].value.length > 0 && ele[i].value.length < 255)
)
return showError(ele[i]);
}
document.getElementById(formId).submit();
}
function getElements(ele) {
let properElements = [];
for (let i = 0; i < ele.length; i++) {
properElements[i] = document.getElementById(ele[i]);
}
return properElements;
}
function showError(ele) {
ele.style.border = "2px solid red";
setTimeout(() => (ele.style.border = ""), 2000);
}
function validEmail(email) {
let expression = email.match(
/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-
9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
);
return expression === null || expression === false ? false : true;
}
function validPhone(phn) {
if (phn[0] == 0) return false;
return phn.length == 10;
}
66
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
my_alert.js:
This JavaScript code defines a custom alert function called CustomAlert that creates
The alert method takes two parameters: message (the message to be displayed) and
title (optional, the title of the dialog box). Inside the method, a new dialog box is
dialogoverlay and dialogbox elements are retrieved and their styles are modified to
display the dialog box overlay and box itself. The dialogboxhead, dialogboxbody, and
dialogboxfoot elements are displayed or hidden based on the presence of a title. The
The ok method is called when the "OK" button is clicked. It hides the dialog box and
The myAlert function is defined to handle the display of alerts. It takes a msg
parameter, which is in the format "status: message". The status and message are
extracted from the msg parameter using split. The console.log statements are there for
debugging purposes. Finally, the customAlert.alert method is called with the extracted
67
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
function CustomAlert() {
this.alert = function (message, title) {
document.body.innerHTML +=
'<div id="dialogoverlay"></div><div id="dialogbox" class="slit-in-
vertical"><div><div id="dialogboxhead"></div><div id="dialogboxbody"></div><div
id="dialogboxfoot"></div></div></div>';
dialogbox.style.top = "100px";
dialogoverlay.style.display = "block";
dialogbox.style.display = "block";
document.getElementById("dialogboxhead").style.display = "block";
this.ok = function () {
document.getElementById("dialogbox").style.display = "none";
document.getElementById("dialogoverlay").style.display = "none";
};
}
function myAlert(msg) {
let status = msg.split(": ")[0];
let message = msg.split(": ")[1];
console.log(status);
console.log(message);
customAlert.alert(message, status);
}
68
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
@charset "ISO-8859-1";
@import url("https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/4.7.0/css/font-awesome.min.css");
/* ---------------Animation---------------- */
.slit-in-vertical {
-webkit-animation: slit-in-vertical 0.45s ease-out both;
animation: slit-in-vertical 0.45s ease-out both;
}
@-webkit-keyframes slit-in-vertical {
0% {
-webkit-transform: translateZ(-800px) rotateY(90deg);
transform: translateZ(-800px) rotateY(90deg);
opacity: 0;
}
54% {
-webkit-transform: translateZ(-160px) rotateY(87deg);
transform: translateZ(-160px) rotateY(87deg);
opacity: 1;
}
100% {
-webkit-transform: translateZ(0) rotateY(0);
transform: translateZ(0) rotateY(0);
}
}
@keyframes slit-in-vertical {
0% {
-webkit-transform: translateZ(-800px) rotateY(90deg);
transform: translateZ(-800px) rotateY(90deg);
opacity: 0;
}
54% {
-webkit-transform: translateZ(-160px) rotateY(87deg);
transform: translateZ(-160px) rotateY(87deg);
opacity: 1;
}
100% {
-webkit-transform: translateZ(0) rotateY(0);
transform: translateZ(0) rotateY(0);
}
}
69
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
/*---------------#region Alert--------------- */
#dialogoverlay{
display: none;
opacity: .8;
position: fixed;
top: 0px;
left: 0px;
background: #707070;
width: 100%;
z-index: 10;
}
#dialogbox{
display: none;
position: absolute;
background: rgb(0, 47, 43);
border-radius:7px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.575);
transition: 0.3s;
width: 40%;
z-index: 10;
top:0;
left: 0;
right: 0;
margin: auto;
}
#dialogbox:hover {
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.911);
}
.container {
padding: 2px 16px;
}
.pure-material-button-contained {
position: relative;
display: inline-block;
box-sizing: border-box;
border: none;
border-radius: 4px;
padding: 0 16px;
min-width: 64px;
height: 36px;
vertical-align: middle;
text-align: center;
70
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
text-overflow: ellipsis;
text-transform: uppercase;
color: rgb(var(--pure-material-onprimary-rgb, 255, 255, 255));
background-color: rgb(var(--pure-material-primary-rgb, 0, 77, 70));
/* background-color: rgb(1, 47, 61) */
box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0,
0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
font-family: var(--pure-material-font, "Roboto", "Segoe UI",
BlinkMacSystemFont, system-ui, -apple-system);
font-size: 14px;
font-weight: 500;
line-height: 36px;
overflow: hidden;
outline: none;
cursor: pointer;
transition: box-shadow 0.2s;
}
.pure-material-button-contained::-moz-focus-inner {
border: none;
}
/* ---------------Overlay--------------- */
.pure-material-button-contained::before {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: rgb(var(--pure-material-onprimary-rgb, 255, 255, 255));
opacity: 0;
transition: opacity 0.2s;
}
/* Ripple */
.pure-material-button-contained::after {
content: "";
position: absolute;
left: 50%;
top: 50%;
border-radius: 50%;
padding: 50%;
width: 32px; /* Safari */
height: 32px; /* Safari */
background-color: rgb(var(--pure-material-onprimary-rgb, 255, 255, 255));
71
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
opacity: 0;
transform: translate(-50%, -50%) scale(1);
transition: opacity 1s, transform 0.5s;
}
/* Hover, Focus */
.pure-material-button-contained:hover,
.pure-material-button-contained:focus {
box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.2), 0 4px 5px 0 rgba(0, 0, 0,
0.14), 0 1px 10px 0 rgba(0, 0, 0, 0.12);
}
.pure-material-button-contained:hover::before {
opacity: 0.08;
}
.pure-material-button-contained:focus::before {
opacity: 0.24;
}
.pure-material-button-contained:hover:focus::before {
opacity: 0.3;
}
/* Active */
.pure-material-button-contained:active {
box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), 0 8px 10px 1px rgba(0, 0, 0,
0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12);
}
.pure-material-button-contained:active::after {
opacity: 0.32;
transform: translate(-50%, -50%) scale(0);
transition: transform 0s;
}
/* Disabled */
.pure-material-button-contained:disabled {
color: rgba(var(--pure-material-onsurface-rgb, 0, 0, 0), 0.38);
background-color: rgba(var(--pure-material-onsurface-rgb, 0, 0, 0), 0.12);
box-shadow: none;
cursor: initial;
}
.pure-material-button-contained:disabled::before {
opacity: 0;
}
72
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
.pure-material-button-contained:disabled::after {
opacity: 0;
}
The “header.jsp” file contains the code for the header or navbar section of the website.
It includes the logo of Online Café Hub and contains various links.
The code also includes JSP scriptlet tags to dynamically generate additional links
based on the user's session information. If the user is logged in, it checks their privilege
level. If the user has admin privileges, an "Admin" link is added, otherwise, a "Cafe"
73
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
link is added. Additionally, a "Logout" link is included. If the user is not logged in, a
<div class="nav-header">
<div class="logo">
<a href="./home.jsp"><img src="./imgs/logo-light.png" alt="logo"></a>
<script src=""></script>
</div>
<div class="links">
<ul>
<li><a href="./home.jsp">Home</a></li>
<li><a href="./about.jsp">About</a></li>
<li><a href="./menu.jsp">Menu</a></li>
<li><a href="./#contact">Contact</a></li>
<% if (session.getAttribute("id") != null) { %>
<% if (session.getAttribute("privilege") != null) { %>
<li><a
href="./adminElements/token_mgmt.jsp">Admin</a></li>
<% } else { %>
<li><a href="./userElements/cafe.jsp">Cafe</a></li>
<% } %>
<li><a href="./logout">Logout</a></li>
<% } else { %>
<li><a href="./login.jsp">Login</a></li>
<% } %>
</ul>
</div>
</div>
header.css:
@charset "ISO-8859-1";
.nav-header {
width: 100%;
padding: .3rem 6rem;
display: flex;
justify-content: space-between;
box-shadow: 1px 0 10px #000000;
background-color: rgba(0,0,0,0.7);
position: sticky;
top: 0;
}
74
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
.nav-header .links {
width: 70%;
min-height: 100%;
}
.nav-header .links ul {
width: 100%;
height: 100%;
display: flex;
justify-content: space-between;
align-items: center;
list-style: none;
}
.nav-header .links ul li {
padding: .6rem 1rem;
transition: .3s ease-in;
cursor: pointer;
}
.nav-header .links ul li a {
text-decoration: none;
font-size: 1.2rem;
color: #ffffff;
}
The “footer.jsp” contains the structure for the common footer of the Online Café Hub.
75
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
In the first row (div with class "row-1"), there are three divisions. The first division
contains a logo image linking to the "home.jsp" page. The second division contains
contact information, including an email address, phone number, and physical address.
In the second row (div with class "row-2"), there is a paragraph element with copyright
information, including the current year, the name of the website "Online Cafe Hub,"
<div class="footer">
<div class="row-1">
<div class="logo">
<a href="http://localhost:8080/OnlineCafeHub/home.jsp"><img
src="http://localhost:8080/OnlineCafeHub/imgs/logo-light.png" alt="logo"></a>
</div>
<div class="info">
<label class="heading">Contact Us</label>
<ul>
<li><i class="fa-solid fa-envelope"></i><a
href="mailto:[email protected]">[email protected]</a></li>
<li><i class="fa-solid fa-phone"></i><label>+91
7042756653</label></li>
<li><i class="fa-solid fa-location-dot"></i><label>C.R. Park,
Market 2, New Delhi - 19</label></li>
</ul>
</div>
<div class="info">
<label class="heading">Open Hours</label>
<ul>
<li>Monday to Saturday : 10am - 10pm</li>
<li>Sunday : 9am - 11pm</li>
</ul>
</div>
</div>
<div class="row-2">
<p>
<i class="fa-sharp fa-regular fa-copyright"></i>
2023 | Online Cafe Hub | Made By Debaloy Chatterjee | BCSP-064
76
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
</p>
</div>
</div>
footer.css:
@charset "ISO-8859-1";
.footer {
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
bottom: 0;
}
.footer a {
text-decoration: none;
color: #ffffff;
}
.footer .row-1 {
width: 100%;
display: flex;
justify-content: space-around;
align-items: flex-start;
color: #ffffff;
background-color: rgba(0,0,0,0.8);
padding: 4rem;
}
77
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
.footer .row-2 {
padding: 1.4rem 0;
}
.footer .row-2 p {
font-size: 1rem;
letter-spacing: .2rem;
font-weight: bold;
}
78
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
The “e_notfound.jsp” is the default page for 404 Errors (page not found). This contains
the simple Error message and a link to go back to the home page. Embedded styling
html {
height: 100%;
}
body{
font-family: 'Lato', sans-serif;
color: #888;
margin: 0;
}
#main{
display: table;
width: 100%;
height: 100vh;
text-align: center;
}
.fof{
display: table-cell;
vertical-align: middle;
}
.fof h1{
font-size: 50px;
display: inline-block;
padding-right: 12px;
79
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
@keyframes type{
from{box-shadow: inset -3px 0px 0px #888;}
to{box-shadow: inset -3px 0px 0px transparent;}
}
</style>
</head>
<body>
<div id="main">
<div class="fof">
<h1>Error 404</h1>
<h2>Page Not Found</h2>
<h3><a href="http://localhost:8080/OnlineCafeHub/"
style="text-decoration: none;">Home</a></h3>
</div>
</div>
</body>
</html>
accessed without authentication, the user will be directed to this page where they will
html {
height: 100%;
}
80
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
body{
font-family: 'Lato', sans-serif;
color: #888;
margin: 0;
}
#main{
display: table;
width: 100%;
height: 100vh;
text-align: center;
}
.fof{
display: table-cell;
vertical-align: middle;
}
.fof h1{
font-size: 50px;
display: inline-block;
padding-right: 12px;
animation: type .5s alternate infinite;
}
@keyframes type{
from{box-shadow: inset -3px 0px 0px #888;}
to{box-shadow: inset -3px 0px 0px transparent;}
}
</style>
</head>
<body>
<div id="main">
<div class="fof">
<h1>Unauthorized</h1>
<h2>Please login to browse the features.</h2>
<h3><a href="http://localhost:8080/OnlineCafeHub/login.jsp"
style="text-decoration: none;">Login</a></h3>
</div>
</div>
</body>
</html>
81
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
The “common.css” has the default style configurations for the other web pages of the
@charset "ISO-8859-1";
@import
url('https://fonts.googleapis.com/css2?family=Fira+Sans:ital,wght@0,100;0,200
;0,300;0,400;0,500;0,600;1,100;1,200;1,300;1,400;1,500;1,600&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Fira Sans', sans-serif;
}
html {
scroll-behavior: smooth;
}
.alt-color-1 {
background-color: rgb(255, 232, 170);
}
.alt-color-2 {
background-color: #ffd66f;
}
.note {
width: 80%;
}
.note .heading {
font-size: 1.6rem;
color: red;
}
.note .content {
font-size: 1.4rem;
}
82
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
The “home.jsp” page is the landing page of Online Café Hub. It begins with page
directives and HTML structure. In the head section, it includes various CSS stylesheets
and JavaScript files for styling and functionality. It also includes the Font Awesome
The body section starts with including the header.jsp file, which generates the header
section of the page. The main content of the home page is divided into different
sections: welcome message, about section, and contact section. Each section contains
relevant content and may include images. The contact section includes a form for users
to submit their contact information and a JavaScript function to validate the form
fields.
The code also includes the footer.jsp file, which generates the footer section of the
page. Lastly, there are JavaScript functions to handle alerts, validate form fields, and
83
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<script src="https://kit.fontawesome.com/ba1aeb3e9d.js"
crossorigin="anonymous"></script>
</head>
<body style="position: relative;">
<%@include file="./header.jsp" %>
<div class="main-body">
<section id="welcome-msg">
<img src="./imgs/home/home-3.jpg" alt="bg" />
<div class="container">
<div class="heading-2">Welcome To</div>
<div class="heading-1">Online Cafe Hub</div>
<div class="content">
This site aims to provide a friendly and aesthetic
feel and experience to you. We hope you enjoy your time with us!
</div>
<a href="./login.jsp">Register</a>
</div>
</section>
<section id="about">
<div class="text-content">
<div class="heading">About Online Cafe Hub</div>
<div class="content">
<p>
Online Cafe Hub aims to provide a safe cyber
space where users can come to spend their time ordering food as well as chat
with strangers. We want to provide an aesthetic and fun place where people
can come to to relax.
</p>
</div>
<a href="./about.jsp">Read More</a>
</div>
<div class="img-content">
<img src="./imgs/home/card-1.jpg" alt="img" />
</div>
</section>
<section id="contact">
<input type="hidden" id="status" value="<%=
session.getAttribute("id") != null ? session.getAttribute("id").toString() :
"null" %>" />
<div class="heading">Contact Us</div>
<form id="contact-form" action="contact" method="POST">
84
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
</div>
<script src="./scripts/fieldValidation.js"></script>
<script>
let status = document.getElementById("status");
if (showAlert()) {
myAlert(status.value);
status.value = "null";
}
function showAlert() {
return status.value.includes('Success') ||
status.value.includes('Error');
}
function contact() {
validateFields(['email', 'subject', 'message'], 'contact-
form');
}
</body>
</html>
home.css:
@charset "ISO-8859-1";
.main-body {
width: 100%;
display: flex;
flex-direction: column;
85
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
margin-top: 8rem;
}
#welcome-msg {
width: 100%;
height: 37rem;
display: flex;
justify-content: center;
align-items: center;
}
#welcome-msg img {
position: absolute;
top: 0;
z-index: -10;
width: 100%;
filter: blur(.5rem);
}
#welcome-msg .container {
width: 50%;
color: #ffffff;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top: -10rem;
gap: 2rem;
}
86
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
#welcome-msg .container a {
width: 40%;
font-size: 1.2rem;
font-weight: bold;
text-transform: uppercase;
letter-spacing: .3rem;
text-align: center;
text-decoration: none;
color: #000000;
background-color: #ffffff;
padding: .8rem 1.4rem;
#about {
width: 100%;
padding: 6rem 8rem;
background-color: #ffffff;
display: flex;
justify-content: space-between;
gap: 3rem;
}
#about .text-content {
width: 50%;
display: flex;
flex-direction: column;
justify-content: flex-start;
gap: 2rem;
}
87
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
#about .text-content a {
background-color: #000000;
color: #ffffff;
text-decoration: none;
width: 30%;
font-size: .9rem;
padding: 1rem 2rem;
text-transform: uppercase;
letter-spacing: .2rem;
font-weight: bold;
text-align: center;
border: 1px solid #ffffff;
transition: .2s ease-in;
}
#about .img-content {
width: 50%;
display: flex;
justify-content: center;
}
#contact {
width: 100%;
padding: 6rem 8rem;
88
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 4rem;
background-color: rgba(221,204,181,0.3);
}
#contact .heading {
font-size: 2rem;
font-weight: bold;
}
#contact form {
width: 60%;
display: flex;
flex-direction: column;
gap: 2rem;
}
outline: none;
border: 2px solid #262626;
89
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
The “login.jsp” file begins with page directives and checks for session attributes to
determine the user's privilege and redirect them accordingly. If the "privilege"
attribute is present, the user is redirected to the admin token management page. If the
The code then constructs the HTML structure of the login page. It includes various
CSS stylesheets for styling and JavaScript files for form field validation and displaying
alerts. The page consists of a registration section and a login section. Each section
contains a form with input fields for name, email, phone number, and password. The
registration form submits data to the "register" endpoint, and the login form submits
The code also includes the header.jsp and footer.jsp files, which generate the header
and footer sections of the page, respectively. Additionally, there is JavaScript code to
90
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<div class="home-container">
<img src="./imgs/home/home-2.jpg" alt="bg" />
<div class="registration">
<form method="POST" action="register" id="registration">
<h2>Registration</h2>
<input type="text" name="name" id="name" placeholder="Full
Name..." class="inputs-default">
<input type="email" name="email" id="email"
placeholder="Email..." class="inputs-default">
<input type="number" name="phn" id="phn" placeholder="Phone
Number..." class="inputs-default">
<input type="password" name="pass" id="pass"
placeholder="Password..." class="inputs-default">
<input type="button" value="Register"
onclick="validateFields(['name', 'email', 'phn', 'pass'], 'registration')"
class="buttons-default">
91
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
</form>
</div>
<div class="login">
<form method="POST" action="login" id="login">
<h2>Login</h2>
<input type="email" name="email" id="lEmail"
placeholder="Email..." class="inputs-default">
<input type="password" name="pass" id="lPass"
placeholder="Password..." class="inputs-default">
<input type="button" value="Login"
onclick="validateFields(['lEmail', 'lPass'], 'login')" class="buttons-
default">
</form>
</div>
</div>
<script type="text/javascript">
let status = document.getElementById("status");
if (showAlert()) {
myAlert(status.value);
status.value = "null";
}
function showAlert() {
return status.value.includes('Success') ||
status.value.includes('Error');
}
</script>
</body>
</html>
login_style.css:
@charset "ISO-8859-1";
.home-container {
padding: 10px;
width: 100%;
height: 100vh;
92
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
display: flex;
justify-content: center;
align-items: center;
}
.home-container img {
width: 100%;
position: absolute;
top: 0;
z-index: -10;
filter: blur(.3rem);
}
.registration, .login {
height: 50%;
flex-grow: 1;
}
.home-container h2 {
width: 50%;
font-size: 2em;
text-align: left;
color: #ffffff;
text-shadow: 2px 2px 8px #000000;
}
.inputs-default {
display: block;
width: 50%;
padding: 10px;
font-size: 1.2em;
transition: .2s ease-in;
border: 2px solid #262626;
}
.inputs-default:hover, .inputs-default:focus {
border: 2px solid #ffd66f;
}
.buttons-default {
93
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
width: 30%;
padding: 12px;
font-size: 1.4em;
cursor: pointer;
background-color: #ffd66f;
color: black;
border: 2px solid #262626;
transition: .2s ease-in;
}
.buttons-default:hover, .buttons-default:focus {
background-color: white;
border: 2px solid #ffd66f;
color: black;
}
.home-container input {
margin: 10px 0;
border: 2px solid #262626;
outline: none;
}
The “about.jsp” file begins with page directives and constructs the HTML structure of
the page. The page includes CSS stylesheets for styling and the Font Awesome library
for icons.
The main content of the page is contained within the "about" section. It provides
information about the website, Online Cafe Hub. The section includes a heading, an
image, and several paragraphs that describe the purpose and features of the platform.
It highlights the concept of creating a virtual space where users can enjoy delicious
food, connect with strangers, and experience the ambiance of a cozy café environment.
94
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
The paragraphs emphasize the importance of shared experiences, diverse food options,
engaging chat features, and the commitment to safety and security. It mentions the
login system, reporting module, and proactive measures taken to ensure a positive and
inclusive atmosphere.
The page also includes a subsection titled "About Developer," which provides
information about the developer of the website. It displays an image, the developer's
name, location, skills, and links to their social media profiles. Additionally, a quote
from the developer expresses gratitude for user feedback and the commitment to
The code includes the header.jsp and footer.jsp files to generate the header and footer
<script src="https://kit.fontawesome.com/ba1aeb3e9d.js"
crossorigin="anonymous"></script>
</head>
<body style="position: relative;">
<%@include file="./header.jsp" %>
<div class="main-body">
95
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<section id="about">
<div class="text-content">
<div class="heading">About Us</div>
<div class="img-content">
<img src="./imgs/logo-light.png" alt="img" />
</div>
<div class="content">
<p>Welcome to <span class="brand">Online Cafe
Hub</span>, a virtual oasis where you can indulge in delicious food and
connect with strangers in a unique and aesthetic online setting. Our mission
is to provide a safe and enjoyable space for users to experience the warmth
and camaraderie of a cozy café environment from the comfort of their own
homes.</p>
96
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
97
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
</div>
</div>
</div>
</div>
</section>
</div>
</body>
</html>
about.css:
@charset "ISO-8859-1";
.main-body {
width: 100%;
}
#about {
width: 100%;
padding: 5rem 10rem;
}
#about .text-content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 2rem;
}
98
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
.dev {
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 1.4rem;
margin-top: 4rem;
}
.dev .card {
width: 30%;
padding: 3rem 2rem;
background-color: #262626;
color: #ffffff;
display: flex;
flex-direction: column;
align-items: center;
gap: 1.4rem;
99
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
.dev .card:hover {
box-shadow: 0 0 8px #262626;
}
100
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
text-decoration: none;
color: #ffffff;
}
.fa-brands {
transition: .2s ease-in;
cursor: pointer;
font-size: 1.4rem;
}
.fa-linkedin:hover {
color: #0077B5;
}
.fa-github:hover {
color: #000000;
background-color: #ffffff;
border-radius: 50%;
}
.fa-twitter:hover {
color: #1C93E4;
}
.fa-instagram:hover {
color: #C42359;
}
The “menu.jsp” file generates the menu page of the Online Café Hub website. It
includes HTML and JSP code to display various sections of the menu, such as quick
bites, fries, sandwiches, burgers, wraps, pasta, Maggie variants, pizzas, bread pizzas,
and combo meals. Each section contains a list of items with their corresponding names
101
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
and prices. The code uses JSP scriptlets (<% %>) to dynamically generate the menu
items based on arrays that store the names and prices of the items. The page also
includes CSS stylesheets and references to external resources like fonts and icons.
<script src="https://kit.fontawesome.com/ba1aeb3e9d.js"
crossorigin="anonymous"></script>
</head>
<body style="position: relative;">
<%@include file="./header.jsp" %>
<div class="main-body">
<section class="about-cafe">
<div class="cafedo-logo">
<img src="./imgs/cafedo.jpg" alt="cafedo" />
</div>
<div class="content">
<p>
CAFEDO, born during the pandemic, offers an immersive
experience. Its captivating design and cozy ambiance provide solace. Indulge
in expertly brewed coffee, heavenly pastries, and gastronomic wonders. CAFEDO
is more than a cafe; it's a place where connections are forged and memories
are made. Join us in celebrating resilience and the beauty found amidst
adversity. Welcome to CAFEDO, where aesthetics meet community.
</p>
</div>
</section>
<div class="menu">
<section class="menu-card">
<div class="title">Quick Bites</div>
<div class="items">
102
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<section class="menu-card">
<div class="title">Fries</div>
<div class="items">
<%! String[] friesNames = {"Salted Fries", "Masala
Fries", "Peri Peri Fries", "Cheesy Fries", "Mayo Spicy Fries"}; %>
<%! String[] friesPrices = {"120", "140", "150",
"160", "150"}; %>
<section class="menu-card">
<div class="title">Sandwich</div>
<div class="items">
<%! String[] sandwichNames = {"Mix Veggie", "Cheese
Blast", "Tandoori Potato", "Cottage Cheese", "Ham And Cheese", "Salami And
Cheese", "Chicken Chunky", "Chicken Egg Club", "Chicken Veggie Club"}; %>
<%! String[] sandwichPrices = {"99", "90", "120",
"150", "150", "120", "130", "160", "150"}; %>
103
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<div class="item">
<div class="name"><%= friesNames[i] %></div>
<div class="price"><%= friesPrices[i]
%></div>
</div>
<% } %>
</div>
</section>
<section class="menu-card">
<div class="title">Burger</div>
<div class="items">
<%! String[] burgerNames = {"Classic Veg", "Herb &
Chilly", "BBQ Veg", "Cottage Cheese & Ranch", "Cottage Cheese & Caesar",
"Classic Chicken", "Fried Chicken", "Fatty Chicken", "BBQ Cheese & Chicken",
"Jalapeno Cheese & Chicken"}; %>
<%! String[] burgerPrices = {"90", "100", "110",
"140", "140", "140", "160", "200", "150", "150"}; %>
<section class="menu-card">
<div class="title">Wrap</div>
<div class="items">
<%! String[] wrapNames = {"All Veggie", "Shroom &
Cheese", "Cottage Cheese", "Chicken Chunky", "Fried Chicken", "BBQ Chicken
Dominator"}; %>
<%! String[] wrapPrices = {"109", "109", "129",
"129", "149", "179"}; %>
104
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<section class="menu-card">
<div class="title">Pasta</div>
<div class="items">
<%! String[] pastaNames = {"White Sauce Veg", "Red
Sauce Veg", "White Sauce Chicken", "Red Sauce Chicken", "Home Style"}; %>
<%! String[] pastaPrices = {"150", "140", "180",
"170", "160"}; %>
<section class="menu-card">
<div class="title">Maggie Varient</div>
<div class="items">
<%! String[] maggieNames = {"Plain", "Double Spice",
"Veggie", "Shrooms", "Peri Peri", "Double Cheese", "Chicken Chunky", "Peri
Peri & Cheese", "Chilly Garlic Chicken"}; %>
<%! String[] maggiePrices = {"50", "60", "70", "70",
"60", "80", "90", "90", "90"}; %>
<section class="menu-card">
<div class="title">Pizza</div>
<div class="items">
<%! String[] pizzaNames = {"Margherita", "Corn",
"Onion Capsicum", "Shrooms", "Farmhouse", "Cottage Cheese", "Salami & Onion",
"Sausage & Onion", "Chunky Chicken", "Fried Chicken", "Chicken Dominator"};
%>
<%! String[] pizzaPrices = {"160", "160", "160",
"170", "180", "200", "190", "190", "190", "200", "220"}; %>
105
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<section class="menu-card">
<div class="title">Bread Pizza</div>
<div class="items">
<%! String[] breadPizzaNames = {"Margherita", "Corn",
"Onion Capsicum", "Shrooms", "Farmhouse", "Cottage Cheese", "Sausage &
Onion", "Chunky Chicken", "Fried Chicken", "Chicken Dominator"}; %>
<%! String[] breadPizzaPrices = {"70", "70", "70",
"80", "90", "100", "100", "100", "110", "120"}; %>
<section class="menu-card">
<div class="title">Combo</div>
<div class="items">
<%! String[] comboNames = {"Classic Veg Burger +
Sprite / Coke", "Classic Chicken Burger + Sprite / Coke", "All Veggie Wrap +
Sprite / Coke", "Chicken Wrap + Sprite / Coke", "Veg Sub + Sprite / Coke",
"Chicken Sub + Sprite / Coke"}; %>
<%! String[] comboPrices = {"99", "140", "110",
"140", "140", "160"}; %>
106
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<% } %>
</div>
</section>
</div>
</div>
</body>
</html>
menu.css:
@charset "ISO-8859-1";
.main-body {
width: 100%;
display: flex;
flex-direction: column;
align-items: space-around;
gap: 4rem;
padding: 5rem 4rem;
}
.about-cafe {
display: flex;
justify-content: center;
align-items: center;
gap: 4rem;
}
.about-cafe .cafedo-logo {
width: 20%;
}
.about-cafe .content {
width: 40%;
font-size: 1.4rem;
letter-spacing: .08rem;
line-height: 2.4rem;
text-align: justify;
}
107
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
.menu {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 2rem;
padding: 2rem;
}
.menu-card {
border: 2px solid #262626;
display: flex;
flex-direction: column;
gap: 1.4rem;
padding: 2rem;
box-shadow: 0 0 4px #1C295E;
background-color: #1C295E;
color: #ffd66f;
transition: .2s ease-in;
}
.menu-card:hover {
box-shadow: 0 0 8px #1C295E;
text-shadow: 0 0 4px #ffd66f;
}
.menu-card .title {
font-size: 1.6rem;
font-weight: bold;
text-align: center;
text-transform: uppercase;
letter-spacing: -.08rem;
}
.menu-card .items {
display: flex;
flex-direction: column;
gap: 1.2rem;
}
108
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
The “userHeader.jsp” is the same as “header.jsp” but it contains certain links that only
come visible when the user is browsing the café, reports, feedback, and my account
pages.
<link rel="stylesheet"
href="../stylesheets/adminElements/adminCommon.css" />
<link rel="stylesheet" href="../stylesheets/userElements/report.css" />
<link rel="stylesheet" href="../stylesheets/userElements/feedback.css" />
<link rel="stylesheet" href="../stylesheets/userElements/my_account.css"
/>
<link rel="stylesheet" href="../stylesheets/userElements/cafe.css" />
</head>
<body>
<div class="nav-header">
<div class="logo">
<a href="../home.jsp"><img src="../imgs/logo-light.png"
alt="logo"></a>
</div>
<div class="links">
<ul>
109
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<li><a href="../home.jsp">Home</a></li>
<li><a href="../menu.jsp" target="_blank">Menu</a></li>
<li><a href="./cafe.jsp">Cafe</a></li>
<li><a href="./report.jsp">Report</a></li>
<li><a href="./feedback.jsp">Feedback</a></li>
<li><a href="./my_account.jsp">My Account</a></li>
<li><a href="../logout">Logout</a></li>
</ul>
</div>
</div>
information from the "tables" table in the "onlinecafehub" database, and dynamically
generates HTML forms for each table. The code uses a custom Table class to handle
the database operations. Inside the loop, it retrieves the total number of chairs and
the number of chairs in use for each table. Based on the availability of chairs, it assigns
CSS classes to the form elements and disables the "Join" button if the table is full.
The generated forms include hidden input fields for table ID and action, and a label
displaying the number of chairs in use and the total number of chairs. Finally, it
includes header and footer JSP files to complete the HTML structure of the page.
<section>
<div id="cafe-area">
<%!
110
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
public Table() {
try {
connection = DriverManager.getConnection(url, user,
pass);
selectTables = connection.prepareStatement("SELECT *
FROM tables");
} catch(SQLException e) {
e.printStackTrace();
}
}
return resultSet;
}
}
%>
<%
Table table = new Table();
ResultSet tables = table.getTables();
111
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
</body>
</html>
cafe.css:
@charset "ISO-8859-1";
#cafe-area {
width: 100%;
padding: 4rem 6rem;
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 2rem;
}
#cafe-area form {
border: 2px solid red;
padding: 5rem 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: .6rem;
border-radius: 2rem;
background-color: #ffd66f;
}
112
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
border-radius: 1.2rem;
background-color: #262626;
color: #ffffff;
font-weight: bold;
transition: .2s ease-in;
}
#cafe-area .full {
border: 2px solid red;
transition: .2s ease-in;
}
#cafe-area .full:hover {
box-shadow: 0 0 4px red;
}
#cafe-area .available {
border: 2px solid #262626;
transition: .2s ease-in;
}
#cafe-area .available:hover {
box-shadow: 0 0 4px #262626;
}
The “chatroom.jsp” page displays a chat container with a chat window and a form for
sending messages. It also includes a form for leaving the chat room and external links
for ordering food. The JavaScript code establishes a WebSocket connection to a chat
113
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
server using the user's session attributes. It handles incoming messages, dynamically
creates message components, and appends them to the chat window. It also sends user
<form id="chatform">
<div id="chat-window"></div>
<div class="chat-options">
<input type="hidden" name="username" value="<%=
session.getAttribute("name").toString() + " : [ " +
session.getAttribute("id") + " ]" %>" />
<input type="text" name="message" id="message" />
<input type="button" value="Send" onclick="return
sendMessage();" />
</div>
</form>
</div>
<script>
window.addEventListener('onbeforeunload', e => {
document.getElementById("leave-links").submit();
114
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
return true;
});
wsCon.onmessage = e => {
let chatWindow = document.getElementById("chat-window");
// Creating the message component
let msgDiv = document.createElement('div');
msgDiv.classList.add('msgDiv', alter ? 'msg-div-1' : 'msg-div-
2');
alter = !alter;
msgDiv.append(userDiv, chatDiv);
chatWindow.append(msgDiv);
msgDiv.scrollIntoView({behavior: "smooth"});
}
wsCon.onerror = e => {
console.log("Error" + e);
}
function sendMessage() {
let msgElement = document.getElementById('message');
115
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
if (msg) {
// Append the tableid along with the message
msg = "<%= session.getAttribute("tableid").toString() %>|" +
msg;
wsCon.send(msg);
}
msgElement.value = "";
}
</script>
</body>
</html>
chatroom.css:
@charset "ISO-8859-1";
.chat-container {
width: 100%;
height: 100vh;
padding: 2rem 4rem;
display: flex;
flex-direction: column;
gap: 2rem;
}
#leave-links ul {
list-style: none;
display: flex;
justify-content: space-around;
align-items: center;
}
116
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
#chatform {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
gap: .6rem;
}
#chat-window {
width: 100%;
display: flex;
flex-direction: column;
gap: .8rem;
font-size: 1.4rem;
padding: .8rem 1rem;
height: 75vh;
outline: none;
border: 2px solid #262626;
box-shadow: 0 0 4px #262626;
background-color: #ffffff;
overflow-y: scroll;
}
#chatform .chat-options {
border: 2px solid #262626;
box-shadow: 0 0 2px #262626;
width: 100%;
display: flex;
justify-content: space-between;
gap: 1rem;
padding: .8rem 1rem;
}
117
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
.msgDiv {
word-break: break-all;
padding: .8rem;
border-radius: 0 1.4rem 1.4rem 1.4rem;
display: flex;
flex-direction: column;
gap: .6rem;
}
.msg-div-1 {
background-color: #ffd66f;
}
.msg-div-2 {
background-color: #ffe6a8;
}
.username {
118
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
text-decoration: underline;
font-weight: bold;
font-size: 1.2rem;
}
The “report.jsp” page displays a form for reporting an offender, a table showing the
user's previous reports, and a note section. The Java code within the JSP handles
database operations related to reports. The JavaScript code includes functions for
validating the report form, displaying alerts based on the report status, and submitting
the form. It also resets the status attribute of the user's session.
<div class="report_table">
<div style="
padding: .6rem;
119
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
font-size: 1.4rem;
font-weight: bold;
text-align: center;
">Your Reports</div>
<%!
public class Report {
String url = Config.getDbUrl();
String user = Config.getDbUser();
String pass = Config.getDbPass();
public Report() {
try {
connection = DriverManager.getConnection(url,
user, pass);
selectReports =
connection.prepareStatement("SELECT * FROM reports");
} catch(SQLException e) {
e.printStackTrace();
}
}
return resultSet;
}
}
%>
<%
Report feedback = new Report();
ResultSet reports = feedback.getReports();
Boolean alternate = true;
%>
<div class="report__table">
<div class="report__table-head">
<div>ID</div>
120
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<div>Offender ID</div>
<div>Reporter ID</div>
<div>Reason</div>
<div>Date</div>
<div>Time</div>
<div>Action</div>
</div>
<div class="note">
<div class="heading">Note:</div>
<div class="content">
Log of each report is made on the admin site. Make sure your
report is genuine else, action will be taken against you.
</div>
</div>
</div>
<script>
let status = document.getElementById("status");
if (showAlert()) {
121
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
myAlert(status.value);
status.value = "null";
}
function showAlert() {
return status.value.includes('Success') ||
status.value.includes('Error');
}
function report() {
document.getElementById("action").value = "report";
validate();
}
function validate() {
if (!document.getElementById('userid').value.length ||
document.getElementById('userid').value < 0)
return myAlert("Error: Please enter User ID. User ID can only
be a positive integer.");
if (!document.getElementById('reason').value.length ||
document.getElementById('reason').value.length > 255)
return myAlert("Error: Please enter a reason. Reason should
not exceed 255 characters.");
document.getElementById('report_form').submit();
}
</body>
</html>
report.css:
@charset "ISO-8859-1";
._container {
width: 100%;
padding: 6rem 8rem;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
122
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
gap: 4rem;
}
#report_form {
width: 30%;
display: flex;
flex-direction: column;
gap: 1.2rem;
}
#report_form input {
padding: .6rem .8rem;
font-size: 1.4rem;
outline: none;
border: 2px solid #262626;
transition: .2s ease-in;
}
#report_form input[type=button] {
background-color: #ffd66f;
font-weight: bold;
color: #000000;
cursor: pointer;
}
.report_table {
border: 2px solid black;
width: 100%;
}
.report__table {
border: 2px solid black;
display: flex;
flex-direction: column;
123
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
position: relative;
font-size: 1.4rem;
max-height: 90%;
}
.report__table-head {
display: grid;
grid-template-columns: repeat(7, 1fr);
font-weight: bold;
background-color: #000000;
color: #ffffff;
padding: .4rem;
}
.report__table-body {
display: flex;
flex-direction: column;
}
.report__table-body-row {
display: grid;
grid-template-columns: repeat(7, 1fr);
padding: .4rem;
}
The “feedback.jsp” page displays a form for submitting feedback, which consists of a
textarea for entering a message and a submit button. The JavaScript code handles the
validation of the form, displays alerts based on the feedback status, and submits the
form. The status attribute of the user's session is reset. The code also includes header
124
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<script>
let status = document.getElementById("status");
if (showAlert()) {
myAlert(status.value);
status.value = "null";
}
function showAlert() {
return status.value.includes('Success') ||
status.value.includes('Error');
}
function feedback() {
document.getElementById("action").value = "feedback";
validate();
}
function validate() {
if (!document.getElementById('message').value.length ||
document.getElementById('message').value.length > 255)
return myAlert("Error: Please enter a reason. Reason should
not exceed 255 characters.");
document.getElementById('feedback_form').submit();
}
</body>
</html>
125
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
The “my_account.jsp” page displays the user's details such as user ID, name, email,
phone number, tokens, and violations. The information is retrieved from a MySQL
database using JDBC. The page also provides forms for updating the user's email,
phone number, and password. The JavaScript code handles form validation, displays
alerts based on the status, and resets the status attribute of the user's session. The
code includes header and footer files as well as a JavaScript file for field validation.
<div class="acc__information">
<% int user_id =
Integer.parseInt(session.getAttribute("id").toString()); %>
<%
String url = Config.getDbUrl();
String user = Config.getDbUser();
String pass = Config.getDbPass();
try {
String query = "SELECT u_email,u_phn,u_tokens,violations
FROM users WHERE u_id=?";
pst = con.prepareStatement(query);
pst.setInt(1, user_id);
126
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
rs = pst.executeQuery();
rs.next();
} catch (SQLException e) {
e.printStackTrace();
}
%>
<div class="details">
<label>User ID:</label>
<label><%= session.getAttribute("id").toString() %></label>
</div>
<div class="details">
<label>Name:</label>
<label><%= session.getAttribute("name").toString() %></label>
</div>
<div class="details">
<label>Email:</label>
<label><%= rs.getString("u_email") %></label>
</div>
<div class="details">
<label>Phone Number:</label>
<label><%= rs.getString("u_phn") %></label>
</div>
<div class="details">
<label>Tokens:</label>
<label><%= rs.getString("u_tokens") %></label>
</div>
<div class="details">
<label>Violations:</label>
<label><%= rs.getString("violations") %></label>
</div>
</div>
<div class="update-info">
<form id="update-email" class="update-form" method="POST"
action="../update">
<input type="hidden" name="action" value="email" />
<input type="email" name="email" id="email_ue"
placeholder="Enter New Email...">
<input type="password" name="password" id="password_ue"
placeholder="Enter Password..." />
<input type="button" value="Update Email"
onclick="validateFields(['email_ue', 'password_ue'], 'update-email')" />
</form>
<form id="update-phn" class="update-form" method="POST"
action="../update">
<input type="hidden" name="action" value="phn" />
127
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
</div>
<script src="../scripts/fieldValidation.js"></script>
<script>
let status = document.getElementById("status");
if (showAlert()) {
myAlert(status.value);
status.value = "null";
}
function showAlert() {
return status.value.includes('Success') ||
status.value.includes('Error');
}
</body>
</html>
128
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
my_account.css:
@charset "ISO-8859-1";
.acc__information {
border: 2px solid #262626;
width: 50%;
padding: 2rem;
display: flex;
flex-direction: column;
justify-content: center;
gap: 1rem;
transition: .2s ease-in;
box-shadow: 0 0 4px #262626;
border-radius: 2rem;
}
.acc__information:hover {
border: 2px solid #ffd66f;
box-shadow: 0 0 4px #ffd66f;
}
.acc__information .details {
display: grid;
grid-template-columns: 1fr 1fr;
font-size: 1.4rem;
}
.update-info {
width: 80%;
display: flex;
flex-direction: column;
gap: 4rem;
padding: 2rem;
}
.update-form {
border: 2px solid #262626;
box-shadow: 0 0 4px #262626;
display: flex;
gap: 1.2rem;
padding: 1.4rem;
transition: .2s ease-in;
129
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
.update-form:hover {
box-shadow: 0 0 8px #262626;
}
.update-form input {
width: 35%;
padding: .6rem .8rem;
font-size: 1.2rem;
outline: none;
border: 2px solid #262626;
transition: .2s ease-in;
}
.update-form input[type=button] {
width: 30%;
background-color: #ffd66f;
font-weight: bold;
color: #000000;
cursor: pointer;
}
.update-form input[type=button]:hover {
background-color: #ffffff;
border: 2px solid #ffd66f;
}
The “adminHeader.jsp” is the same as “header.jsp” but this incorporates a few extra
130
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<link rel="stylesheet"
href="../stylesheets/adminElements/adminCommon.css" />
<link rel="stylesheet" href="../stylesheets/adminElements/token_mgmt.css"
/>
<link rel="stylesheet" href="../stylesheets/adminElements/table_mgmt.css"
/>
<link rel="stylesheet" href="../stylesheets/adminElements/user_mgmt.css"
/>
<link rel="stylesheet" href="../stylesheets/adminElements/feedbacks.css"
/>
<link rel="stylesheet" href="../stylesheets/adminElements/reports.css" />
<link rel="stylesheet" href="../stylesheets/userElements/report.css" />
<script src="../scripts/my_alert.js"></script>
<link rel="stylesheet" href="../stylesheets/customAlert.css">
</head>
<body>
<div class="nav-header">
<div class="logo">
<a href="../home.jsp"><img src="../imgs/logo-light.png"
alt="logo"></a>
</div>
<div class="links">
<ul>
<li><a href="../home.jsp">Home</a></li>
<li><a href="./token_mgmt.jsp">Token Management</a></li>
<li><a href="./table_mgmt.jsp">Table Management</a></li>
<li><a href="./user_mgmt.jsp">User Management</a></li>
131
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<li><a href="./reports.jsp">Reports</a></li>
<li><a href="./feedbacks.jsp">Feedbacks</a></li>
<li><a href="../logout">Logout</a></li>
</ul>
</div>
</div>
adminCommon.css:
@charset "ISO-8859-1";
.admin__container {
height: 80vh;
display: flex;
justify-content: space-around;
align-items: center;
}
#admin__form {
border: 1px solid black;
height: 60%;
width: 40%;
padding: 4%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: rgba(255,218,175,0.4);
border-radius: 24px;
box-shadow: 0 0 6px black;
}
.admin__inputs {
width: 100%;
display: flex;
flex-direction: column;
gap: 10px;
}
.admin__inputs input {
font-size: 1.4rem;
padding: .6rem .8rem;
border: 2px solid #ffd66f;
outline: none;
transition: .2s ease-in;
}
132
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
.admin__buttons input {
margin-top: 1.4rem;
font-size: 1.2rem;
padding: .6rem .8rem;
background-color: #ffd66f;
border: 2px solid #000000;
color: black;
cursor: pointer;
transition: .2s ease-in;
}
.admin__buttons input:nth-child(1) {
margin-right: 1.6rem;
}
.admin__note-heading {
color: #ff0000;
}
The “token_mgmt.jsp” (token management) page includes a form where admins can
add or remove tokens for a specific user with reason. The form has inputs for user ID,
tokens, and reason. There are buttons for adding or removing tokens, which trigger
JavaScript functions for form validation and submission. The code also displays alerts
based on the status, resets the status attribute of the user's session, and includes a
note about access restrictions. The header and footer files are included as well.
133
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<div class="admin__inputs">
<input type="number" name="userid" id="userid"
placeholder="Enter User ID..." />
<input type="number" name="tokens" id="tokens"
placeholder="Enter Tokens..." />
<input type="text" name="reason" id="reason"
placeholder="Enter Reason..." />
</div>
<div class="admin__buttons">
<input type="button" value="Add Tokens" onclick="addTokens()"
/>
<input type="button" value="Remove Tokens"
onclick="removeTokens()" />
</div>
</form>
<div class="admin__note">
<p class="admin__note-heading">Note:</p>
<p class="admin__note-desc">
Only staff with admin level clearance (privilege 1) are
allowed to use this feature. Unauthorized access will be recorded.
</p>
</div>
<script>
let status = document.getElementById("status");
if (showAlert()) {
myAlert(status.value);
status.value = "null";
}
134
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
function showAlert() {
return status.value.includes('Success') ||
status.value.includes('Error');
}
function addTokens() {
document.getElementById("action").value = "add";
validate();
}
function removeTokens() {
document.getElementById("action").value = "remove";
validate();
}
function validate() {
if (!document.getElementById('userid').value.length ||
document.getElementById('userid').value < 0)
return myAlert("Error: Please enter User ID. User ID can
only be a positive integer.")
if (!document.getElementById('tokens').value.length ||
document.getElementById('tokens').value < 0)
return myAlert("Error: Please enter correct tokens.
Tokens can only be positive integers")
if (!document.getElementById('reason').value.length ||
document.getElementById('reason').value.length > 255)
return myAlert("Error: Please enter a reason. Reason
should not exceed 255 characters.");
document.getElementById('admin__form').submit();
}
</script>
</body>
</html>
token_mgmt.css:
@charset "ISO-8859-1";
.token__container {
135
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
height: 80vh;
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
}
The “table_mgmt.jsp” page includes a form that allows administrators to add, update,
or remove tables. The form has input fields for table ID and chairs. The code also
connects to a MySQL database using JDBC and retrieves table data from the "tables"
table. The table data is displayed in a formatted manner on the page, including
columns for ID, chairs, in use, and available. JavaScript functions are used to handle
form validation and submit the form based on the selected action.
<%@page import="java.sql.DriverManager"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@page import="java.sql.*" %>
<%@page import="com.onlinecafehub.config.Config" %>
<% Class.forName(Config.getMySqlDriver()); %>
<div class="admin__inputs">
136
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<div class="admin__buttons">
<input type="button" value="Add Table" onclick="addTable()"
/>
<input type="button" value="Update Table"
onclick="updateTable()" />
<input type="button" value="Remove Table"
onclick="removeTable()" />
</div>
</form>
public Table () {
try {
connection = DriverManager.getConnection(url,
user, pass);
selectTables =
connection.prepareStatement("SELECT * FROM tables");
} catch(SQLException e) {
e.printStackTrace();
}
}
137
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
return resultSet;
}
}
%>
<%
Table table = new Table();
ResultSet tables = table.getActors();
Boolean alternate = true;
%>
<div class="table__table">
<div class="table__table-head">
<div>ID</div>
<div>Chairs</div>
<div>In Use</div>
<div>Available</div>
</div>
<div class="table__table-body">
<% while(tables.next()) { %>
<div class="<%= alternate ? "alt-color" : "" %>
table__table-body-row">
<div><%= tables.getInt("id") %></div>
<div><%= tables.getInt("chairs") %></div>
<div><%= tables.getInt("inuse") %></div>
<div><%= tables.getInt("available") %></div>
</div>
<% alternate = !alternate; %>
<% } %>
</div>
</div>
</div>
<script>
let status = document.getElementById("status");
if (showAlert()) {
myAlert(status.value);
status.value = "null";
}
function showAlert() {
return status.value.includes('Success') ||
status.value.includes('Error');
}
138
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
function addTable() {
document.getElementById("action").value = "add";
validate();
}
function updateTable() {
document.getElementById("action").value = "update";
validate();
}
function removeTable() {
document.getElementById("action").value = "remove";
validate();
}
function validate() {
if
(["update","remove"].includes(document.getElementById("action").value) &&
!document.getElementById('tableid').value.length ||
document.getElementById('tableid').value < 0)
return myAlert("Error: Please enter Table ID. Table ID
can only be a positive integer.");
if
(["add","update"].includes(document.getElementById("action").value) &&
!document.getElementById('chairs').value.length ||
document.getElementById('chairs').value < 0)
return myAlert("Error: Please enter chairs. Chairs can
only be positive integers");
document.getElementById('admin__form').submit();
}
</body>
</html>
139
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
table_mgmt.css:
@charset "ISO-8859-1";
.table__table {
display: flex;
flex-direction: column;
border: 2px solid #000000;
max-height: 90%;
position: relative;
}
.table__table-head {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
border: 2px solid #000000;
width: 40rem;
}
.table__table-head div {
padding: .8rem .6rem;
width: 100%;
font-weight: bold;
}
.table__table-body {
display: flex;
flex-direction: column;
border: 2px solid #000000;
width: 40rem;
overflow-y: scroll;
}
.table__table-body-row {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
border: 2px solid #000000;
width: 100%;
padding: .6rem 1rem;
}
.table__table .alt-color {
background-color: #fcbc83;
}
140
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
The “user_mgmt.jsp” page includes a form that allows administrators to ban or unban
users. The form has input fields for user ID and reason. The code also connects to a
MySQL database using JDBC and retrieves user data from the "users" table. The user
data is displayed in a formatted table, including columns for ID, name, email, phone,
tokens, banned status, and violations. JavaScript functions handle form validation and
<div class="admin__inputs">
<input type="number" name="userid" id="userid"
placeholder="Enter User ID..." />
<input type="text" name="reason" id="reason"
placeholder="Enter Reason..." />
</div>
<div class="admin__buttons">
<input type="button" value="Ban User" onclick="banUser()" />
<input type="button" value="Unban User" onclick="unbanUser()"
/>
</div>
141
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
</form>
public User () {
try {
connection = DriverManager.getConnection(url,
user, pass);
selectUsers = connection.prepareStatement("SELECT
* FROM users");
} catch(SQLException e) {
e.printStackTrace();
}
}
return resultSet;
}
}
%>
<%
User user = new User();
ResultSet users = user.getActors();
Boolean alternate = true;
%>
<div class="user__table">
<div class="user__table-head">
<div>ID</div>
142
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<div>Name</div>
<div>Email</div>
<div>Phone</div>
<div>Tokens</div>
<div>Banned</div>
<div>Violations</div>
</div>
<div class="user__table-body">
<% while(users.next()) { %>
<div class="<%= alternate ? "alt-color" : "" %>
user__table-body-row">
<div><%= users.getInt("u_id") %></div>
<div><%= users.getString("u_name") %></div>
<div onclick="alert('<%=
users.getString("u_email") %>')" style="cursor:pointer; text-decoration:
underline;"><%= users.getString("u_email").length() < 18 ?
users.getString("u_email") : users.getString("u_email").substring(0, 18) +
"..." %></div>
<div><%= users.getString("u_phn") %></div>
<div><%= users.getInt("u_tokens") %></div>
<div><%= users.getString("banned") %></div>
<div><%= users.getInt("violations") %></div>
</div>
<% alternate = !alternate; %>
<% } %>
</div>
</div>
</div>
<div class="admin__note">
<p class="admin__note-heading">Note:</p>
<p class="admin__note-desc">
Only staff with admin level clearance (privilege 1) are
allowed to use this feature. Unauthorized access will be recorded.
</p>
</div>
<script>
let status = document.getElementById("status");
if (showAlert()) {
myAlert(status.value);
status.value = "null";
}
function showAlert() {
143
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
return status.value.includes('Success') ||
status.value.includes('Error');
}
function banUser() {
document.getElementById("action").value = "ban";
validate();
}
function unbanUser() {
document.getElementById("action").value = "unban";
validate();
}
function validate() {
if (!document.getElementById('userid').value.length ||
document.getElementById('userid').value < 0)
return myAlert("Error: Please enter User ID. User ID can
only be a positive integer.");
if (!document.getElementById('reason').value.length ||
document.getElementById('reason').value.length > 255)
return myAlert("Error: Please enter a reason. Reason
should not exceed 255 characters.");
document.getElementById('admin__form').submit();
}
</body>
</html>
user_mgmt.css:
@charset "ISO-8859-1";
.user__container {
height: 80vh;
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
144
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
.user__table {
display: flex;
flex-direction: column;
border: 2px solid #000000;
max-height: 90%;
position: relative;
}
.user__table-head {
display: grid;
grid-template-columns: 5% 20% 25% 13% 10% 10% 10%;
border: 2px solid #000000;
width: 100%;
grid-gap: .5rem;
}
.user__table-head div {
font-weight: bold;
padding: .6rem .4rem;
}
.user__table-body {
display: flex;
flex-direction: column;
border: 2px solid #000000;
width: 100%;
max-height: 20rem;
overflow-y: scroll;
}
.user__table-body-row {
display: grid;
grid-template-columns: 5% 20% 25% 15% 10% 10% 10%;
border: 2px solid #000000;
width: 100%;
grid-gap: .5rem;
}
.user__table-body-row div {
padding: .6rem .4rem;
word-wrap: break-word;
}
.user__table .alt-color {
background-color: #fcbc83;
145
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
The “reports.jsp” page retrieves data from a MySQL database using JDBC to fetch
information from the "reports" table. The retrieved data includes the ID of the report,
offender ID, reporter ID, reason, date, time, and action. This data is displayed in a
formatted table with columns representing the aforementioned attributes. The code
also includes a note section that provides instructions to administrators on how to take
public Report() {
try {
connection = DriverManager.getConnection(url, user,
pass);
146
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
selectReports = connection.prepareStatement("SELECT *
FROM reports");
} catch(SQLException e) {
e.printStackTrace();
}
}
return resultSet;
}
}
%>
<%
Report feedback = new Report();
ResultSet reports = feedback.getReports();
Boolean alternate = true;
%>
<div class="user__table">
<div class="report__table-head">
<div>ID</div>
<div>Offender ID</div>
<div>Reporter ID</div>
<div>Reason</div>
<div>Date</div>
<div>Time</div>
<div>Action</div>
</div>
147
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<div class="admin__note">
<p class="admin__note-heading">Note:</p>
<p class="admin__note-desc">
To take action against an user please go to <a
href="./user_mgmt.jsp">user management</a>.
</p>
</div>
</section>
</body>
</html>
reports.css:
@charset "ISO-8859-1";
.report__table-head {
display: grid;
grid-template-columns: 5% 10% 10% 29% 12% 11% 15%;
border: 2px solid #000000;
width: 100%;
grid-gap: .5rem;
}
.report__table-head div {
font-weight: bold;
padding: .6rem .4rem;
}
.report__table-body-row {
display: grid;
grid-template-columns: 5% 10% 10% 30% 12% 12% 15%;
border: 2px solid #000000;
148
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
width: 100%;
grid-gap: .5rem;
}
.report__table-body-row div {
padding: .6rem .4rem;
word-wrap: break-word;
}
The “feedbacks.jsp” page retrieves data from a MySQL database using JDBC to fetch
information from the "feedback" table. The retrieved data includes the ID of the
feedback, user ID, feedback message, date, and time. This data is displayed in a
formatted table with columns representing the aforementioned attributes. The code
includes a CSS class called "alt-color" to alternate the background color of table rows
149
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
public Feedback() {
try {
connection = DriverManager.getConnection(url, user,
pass);
selectFeedbacks = connection.prepareStatement("SELECT
* FROM feedback");
} catch(SQLException e) {
e.printStackTrace();
}
}
return resultSet;
}
}
%>
<%
Feedback feedback = new Feedback();
ResultSet feedbacks = feedback.getFeedbacks();
Boolean alternate = true;
%>
<div class="user__table">
<div class="feedback__table-head">
<div>ID</div>
<div>User ID</div>
<div>Feedback</div>
<div>Date</div>
<div>Time</div>
</div>
150
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<div onclick="alert('<%=
feedbacks.getString("message") %>')" style="cursor:pointer; text-decoration:
underline;"><%= feedbacks.getString("message").length() < 40 ?
feedbacks.getString("message") : feedbacks.getString("message").substring(0,
40) + "..." %></div>
<div><%= feedbacks.getString("f_date").split(" ")[0]
%></div>
<div><%= feedbacks.getString("f_date").split(" ")[1]
%></div>
</div>
<% alternate = !alternate; %>
<% } %>
</div>
</div>
</div>
</section>
</body>
</html>
feedbacks.jsp:
@charset "ISO-8859-1";
.feedback__table-head {
display: grid;
grid-template-columns: 5% 10% 40% 20% 20%;
border: 2px solid #000000;
width: 100%;
grid-gap: .5rem;
}
.feedback__table-head div {
font-weight: bold;
padding: .6rem .4rem;
}
.feedback__table-body-row {
display: grid;
grid-template-columns: 5% 10% 40% 20% 20%;
border: 2px solid #000000;
width: 100%;
grid-gap: .5rem;
}
151
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
.feedback__table-body-row div {
padding: .6rem .4rem;
word-wrap: break-word;
}
CONFIG PACKAGE
Config.java:
This module provides static getters for Database and Mail Server configuration details
package com.onlinecafehub.config;
152
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
AUTHENTICATION PACKAGE
RegistrationServlet.java:
This servlet is accessible through the “/register” route and accepts on the POST
method. The registration form in “login.jsp” submits the data to this servlet.
If a user tries to register with the “onlinecafehub” domain, it will send an error message.
If the fields are valid, a connection to the database is made and a query is run to check
if the user already exists or not. If user is already registered, an error message is sent
else the password is hashed and stored in the database. Upon success or failure, a
package com.onlinecafehub.authentication;
import com.onlinecafehub.config.Config;
153
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
package com.onlinecafehub.authentication.PasswordHashing;
import java.io.IOException;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@WebServlet("/register")
public class RegistrationServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
RequestDispatcher dispatcher =
request.getRequestDispatcher("login.jsp");
Connection con = null;
String query;
if (u_email.contains("onlinecafehub")) {
request.setAttribute("status", "Error: You are not allowed to use
the onlinecafehub domain to register on this site.");
dispatcher.forward(request, response);
return;
}
try {
String url = Config.getDbUrl();
String user = Config.getDbUser();
String pass = Config.getDbPass();
Class.forName(Config.getMySqlDriver());
154
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
ResultSet rs = pst.executeQuery();
if (rs.isBeforeFirst()) {
request.setAttribute("status", "Error: Email and/or Phone
Number already in use OR user banned.");
dispatcher.forward(request, response);
return;
}
// INSERT RECORD
query = "INSERT INTO users(u_name, u_email, u_phn, u_pass,
u_tokens) VALUES(?, ?, ?, ?, DEFAULT)";
pst = con.prepareStatement(query);
pst.setString(1, u_name);
pst.setString(2, u_email);
pst.setString(3, u_phn);
pst.setString(4, hashedPassword);
if (rowCount > 0) {
request.setAttribute("status", "Success: Account created
successfully!");
} else {
request.setAttribute("status", "Error: Failed to create
account.");
}
dispatcher.forward(request, response);
} catch (Exception e) {
155
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
LoginServlet.java:
This servlet is accessible through the “/login” route and accepts on the POST method.
A connection to the database is made and a query is run to check if the user / admin
package com.onlinecafehub.authentication;
import com.onlinecafehub.config.Config;
package com.onlinecafehub.authentication.PasswordHashing;
import java.io.IOException;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
156
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@WebServlet("/login")
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
RequestDispatcher dispatcher =
request.getRequestDispatcher("index.jsp");
Connection con = null;
String query;
HttpSession session = request.getSession();
try {
String url = Config.getDbUrl();
String user = Config.getDbUser();
String pass = Config.getDbPass();
Class.forName(Config.getMySqlDriver());
con = DriverManager.getConnection(url, user, pass);
ResultSet rs = pst.executeQuery();
dispatcher = request.getRequestDispatcher("login.jsp");
157
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
if (rs.next()) {
String hashedPassword = rs.getString("u_pass");
if (rs.getString("banned").equals("false") &&
ph.verifyPassword(u_pass, hashedPassword)) {
session.setAttribute("id", rs.getInt(1));
session.setAttribute("name", rs.getString("u_name"));
} else {
request.setAttribute("status", "Error: User is banned
or invalid credentials.");
}
} else {
request.setAttribute("status", "Error: Record not
found.");
}
dispatcher.forward(request, response);
} else {
// CHECK IF ADMIN EXISTS
query = "SELECT * FROM admins WHERE a_email=? AND a_pass=?";
PreparedStatement pst = con.prepareStatement(query);
pst.setString(1, u_email);
pst.setString(2, u_pass);
ResultSet rs = pst.executeQuery();
if (rs.next()) {
session.setAttribute("id", rs.getInt(1));
session.setAttribute("privilege", rs.getInt(6));
response.sendRedirect("./adminElements/token_mgmt.jsp");
} else {
request.setAttribute("status", "Error: Record not
found.");
dispatcher = request.getRequestDispatcher("login.jsp");
dispatcher.forward(request, response);
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
158
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
LogoutServlet.java
This servlet is responsible for deleting user session and redirecting them to the
“login.jsp” page.
package com.onlinecafehub.authentication;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import java.io.IOException;
/**
* Servlet implementation class LogoutServlet
*/
@WebServlet("/logout")
public class LogoutServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
WEBSOCKET PACKAGE
ChatWS.java:
The "WebWS.java" file defines a WebSocket server endpoint for the chatting feature.
159
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
determines the endpoint's address that clients can connect to. The {tableId}, {name},
and {userId} are path parameters that clients need to provide when connecting to the
WebSocket.
The class defines various methods annotated with @OnOpen, @OnClose, @OnError,
and @OnMessage. These annotations indicate the behaviour associated with specific
It receives the current session and extracts the path parameters (tableId, name, and
userId) from the connection URL. These parameters are then stored as user properties
in the session, allowing the server to identify and associate the connection with specific
chat participants. The session is also added to the userSessions set, which keeps track
the session associated with the closing connection from the userSessions set.
triggered, printing the error message to the console for debugging purposes.
The @OnMessage method handles incoming messages from clients. It expects messages
extract the table ID, and it retrieves the sender's name and user ID from the session's
160
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
user properties. The method then iterates over the userSessions set and broadcasts the
@OnMessage method. It retrieves the table ID associated with a session from its user
properties.
package com.onlinecafehub.websocket;
import jakarta.websocket.Session;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import jakarta.websocket.OnClose;
import jakarta.websocket.OnError;
import jakarta.websocket.OnMessage;
import jakarta.websocket.OnOpen;
import jakarta.websocket.server.PathParam;
import jakarta.websocket.server.ServerEndpoint;
@ServerEndpoint("/chatws/{tableId}/{name}/{userId}")
public class ChatWS {
private static Set<Session> userSessions = Collections.newSetFromMap(new
ConcurrentHashMap<Session, Boolean>());
@OnOpen
public void onOpen(Session curSession, @PathParam("tableId") String
tableId, @PathParam("name") String name, @PathParam("userId") String userId)
{
curSession.getUserProperties().put("tableId", tableId);
curSession.getUserProperties().put("name", name);
curSession.getUserProperties().put("userId", userId);
userSessions.add(curSession);
}
@OnClose
public void onClose(Session curSession) {
userSessions.remove(curSession);
}
161
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
@OnError
public void onError(Throwable error) {
System.out.println(error);
}
@OnMessage
public void handleMessage(String message, Session userSession) {
// Extract the table ID from the message
String tableId = message.split("\\|")[0];
String actualMessage = message.split("\\|")[1];
return tableId;
162
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
}
}
USER PACKAGE
ChatServlet.java:
This servlet is accessible through the “/chat” route, and depending upon the action
like “join” chatroom or “leave” chatroom, executes certain queries on the “tables” table.
package com.onlinecafehub.user;
import com.onlinecafehub.config.Config;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
/**
* Servlet implementation class ChatServlet
*/
@WebServlet("/chat")
public class ChatServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
163
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
RequestDispatcher dispatcher =
request.getRequestDispatcher("login.jsp");
if (session.getAttribute("id") == null ) {
dispatcher.forward(request, response);
return;
}
int tableid;
String action = request.getParameter("action");
String name = session.getAttribute("name").toString();
int id =
Integer.parseInt(session.getAttribute("id").toString());
try {
Class.forName(Config.getMySqlDriver());
con = DriverManager.getConnection(url, user,
pass);
} catch (SQLException e) {
System.out.println("SQLException: " + e.getMessage());
} catch (ClassNotFoundException e) {
System.out.println("ClassNotFoundException: " +
e.getMessage());
} catch (Exception e) {
e.printStackTrace();
}
try {
if (action.equals("join")) {
164
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
pst.setInt(1, tableid);
if (rowCount > 0) {
session.setAttribute("username", username);
session.setAttribute("tableid", tableid);
response.sendRedirect("./userElements/chatroom.jsp
");
} else {
session.setAttribute("status", "Error: Could not
connect to database.");
response.sendRedirect("./userElements/cafe.jsp");
}
} else if (action.equals("leave")) {
// Decrease inuse of the tableid
tableid =
Integer.parseInt(session.getAttribute("tableid").toString());
query = "UPDATE tables SET inuse=inuse-1 WHERE id=?";
pst = con.prepareStatement(query);
pst.setInt(1, tableid);
if (rowCount > 0) {
response.sendRedirect("./userElements/cafe.jsp");
} else {
session.setAttribute("status", "Error: Could not
connect to database.");
response.sendRedirect("./userElements/chatroom.jsp
");
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
con.close();
} catch(SQLException e) {
e.printStackTrace();
}
}
}
165
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
ContactServlet.java:
This servlet is accessible through the “/contact” route and accepts the POST method.
It creates a session with the smtp mail server of google (gmail) and sends the email to
the destination.
package com.onlinecafehub.user;
import com.onlinecafehub.config.Config;
import jakarta.mail.Authenticator;
import jakarta.mail.Message;
import jakarta.mail.MessagingException;
import jakarta.mail.PasswordAuthentication;
import jakarta.mail.Session;
import jakarta.mail.Transport;
import jakarta.mail.internet.InternetAddress;
import jakarta.mail.internet.MimeMessage;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Properties;
/**
* Servlet implementation class ContactServlet
*/
@WebServlet("/contact")
public class ContactServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
166
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
// Email configuration
String host = Config.getMailServerHost();
String port = Config.getMailServerPort();
String username = Config.getMailServerUser();
String password = Config.getMailServerPass();
String to = "[email protected]";
// Create properties
Properties props = new Properties();
props.put("mail.smtp.host", host);
props.put("mail.smtp.port", port);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
try {
// Create message
Message emailMessage = new MimeMessage(session);
emailMessage.setFrom(new InternetAddress(email));
emailMessage.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(to));
emailMessage.setSubject(subject);
emailMessage.setText(message);
// Send email
Transport.send(emailMessage);
167
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
ReportServlet.java:
This servlet is accessible through the “/report” route and accepts POST method. When
the user submits their report on the “report.jsp” page, the data is sent to this servlet.
The servlet checks if the user is trying to report themselves or not and sends
appropriate message if yes, else it creates a connection to the database and inserts a
new record with necessary details. An appropriate is sent when the database process
is done.
package com.onlinecafehub.user;
import com.onlinecafehub.config.Config;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
168
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* Servlet implementation class ReportServlet
*/
@WebServlet("/report")
public class ReportServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
int reporter_id =
Integer.parseInt(session.getAttribute("id").toString());
int offender_id =
Integer.parseInt(request.getParameter("offenderid"));
if (reporter_id == offender_id) {
session.setAttribute("status", "Error: You cannot report
yourself!");
response.sendRedirect("./userElements/report.jsp");.
return;
}
try {
session.setAttribute("status", null);
169
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
Class.forName(Config.getMySqlDriver());
con = DriverManager.getConnection(url, user, pass);
ResultSet rs = pst.executeQuery();
if (!rs.next()) {
session.setAttribute("status", "Error: User ID not
found.");
} else {
// ADD RECORD TO REPORTS
query = "INSERT INTO
reports(r_date,offender_id,reporter_id,reason,action)
VALUES(DEFAULT,?,?,?,DEFAULT)";
pst = con.prepareStatement(query);
pst.setInt(1, offender_id);
pst.setInt(2, reporter_id);
pst.setString(3, reason);
if (rowCount > 0) {
session.setAttribute("status", "Success: Reported!");
} else {
session.setAttribute("status", "Error: Failed to
report user.");
}
}
response.sendRedirect("./userElements/report.jsp");
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
con.close();
} catch (SQLException e) {
170
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
e.printStackTrace();
}
}
}
FeedbackServlet.java:
This servlet is responsible for taking user feedback and storing it on the database. An
package com.onlinecafehub.user;
import com.onlinecafehub.config.Config;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
/**
* Servlet implementation class FeedbackServlet
*/
@WebServlet("/feedback")
public class FeedbackServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
171
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
int user_id =
Integer.parseInt(session.getAttribute("id").toString());
String message = request.getParameter("message");
try {
session.setAttribute("status", null);
Class.forName(Config.getMySqlDriver());
con = DriverManager.getConnection(url, user, pass);
if (rowCount > 0) {
session.setAttribute("status", "Success: Thank you for your
feedback!");
} else {
172
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
response.sendRedirect("./userElements/feedback.jsp");
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
UpdateSevlet.java:
This servlet is responsible for updating user details, it checks the password first then
only performs the action. When updating password, the password is hashed and then
package com.onlinecafehub.user;
import com.onlinecafehub.authentication.PasswordHashing;
import com.onlinecafehub.config.Config;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
173
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* Servlet implementation class UpdateServlet
*/
@WebServlet("/update")
public class UpdateServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@SuppressWarnings("resource")
protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
HttpSession session = request.getSession();
RequestDispatcher dispatcher =
request.getRequestDispatcher("login.jsp");
if (session.getAttribute("id") == null ) {
dispatcher.forward(request, response);
return;
}
int user_id =
Integer.parseInt(session.getAttribute("id").toString());
session.setAttribute("status", null);
try {
Class.forName(Config.getMySqlDriver());
con = DriverManager.getConnection(url, user, pass);
174
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
} catch (SQLException e) {
System.out.println("SQLException: " + e.getMessage());
} catch (ClassNotFoundException e) {
System.out.println("ClassNotFoundException: " + e.getMessage());
} catch (Exception e) {
e.printStackTrace();
}
ResultSet rs = pst.executeQuery();
rs.next();
if (!ph.verifyPassword(password, oldHashedPassword)) {
session.setAttribute("status", "Error: Invalid password!");
response.sendRedirect("./userElements/my_account.jsp");
return;
}
} catch (SQLException | NoSuchAlgorithmException |
InvalidKeySpecException e) {
e.printStackTrace();
}
try {
switch(action) {
case "email": {
String email = request.getParameter("email");
// CHECK IF THAT EMAIL ALREADY EXISTS
query = "SELECT u_email FROM users WHERE u_email=?";
pst = con.prepareStatement(query);
pst.setString(1, email);
ResultSet rs = pst.executeQuery();
if (rs.isBeforeFirst()) {
session.setAttribute("status", "Error: Email already
in use.");
response.sendRedirect("./userElements/my_account.jsp"
);
175
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
return;
}
// UPDATE EMAIL
query = "UPDATE users SET u_email=? WHERE u_id=?";
pst = con.prepareStatement(query);
pst.setString(1, email);
pst.setInt(2, user_id);
if (rowCount > 0) {
session.setAttribute("status", "Success: Email
Updated Successfully!");
} else {
session.setAttribute("status", "Error: Could not
update email.");
}
} break;
case "phn": {
String phn = request.getParameter("phn");
// CHECK IF THAT PHONE NUMBER ALREADY EXISTS
query = "SELECT u_email FROM users WHERE u_phn=?";
pst = con.prepareStatement(query);
pst.setString(1, phn);
ResultSet rs = pst.executeQuery();
if (rs.isBeforeFirst()) {
session.setAttribute("status", "Error: Phone Number
already in use.");
response.sendRedirect("./userElements/my_account.jsp"
);
return;
}
if (rowCount > 0) {
176
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
case "password": {
// UPDATE PASSWORD
try {
salt = ph.generateSalt();
newHashedPassword = ph.hashPassword(password, salt);
if (rowCount > 0) {
session.setAttribute("status", "Success: Password
Updated Successfully!");
} else {
session.setAttribute("status", "Error: Could not
update email.");
}
} catch (Exception e) {
e.printStackTrace();
}
} break;
default: {
session.setAttribute("status", "Error: Invalid action.");
System.out.println("Wrong action provided.");
}
}
response.sendRedirect("./userElements/my_account.jsp");
} catch (Exception e) {
177
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
e.printStackTrace();
} finally {
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
178
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
ADMIN PACKAGE
TokenMgmtServlet.java:
This servlet gets called when submitting the Token Form in the “token_mgmt.jsp”
“unauthorized” table. If an admin is doing the change, the database processes the query
package com.onlinecafehub.admin;
import com.onlinecafehub.config.Config;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* Servlet implementation class TokenMgmtServlet
*/
@WebServlet("/tokenmgmt")
public class TokenMgmtServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
179
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
dispatcher.forward(request, response);
return;
}
int privilege =
Integer.parseInt(session.getAttribute("privilege").toString());
int admin_id =
Integer.parseInt(session.getAttribute("id").toString());
Boolean isAuthorized = privilege == 1 ? true : false;
try {
session.setAttribute("status", null);
Class.forName(Config.getMySqlDriver());
con = DriverManager.getConnection(url, user, pass);
if (rowCount > 0) {
session.setAttribute("status", "Success: Unauthorized
access recorded.");
} else {
session.setAttribute("status", "Error: Failed to connect
to MySQL.");
180
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
if (pst.executeUpdate() > 0) {
System.out.println("Admin Violations for Admin_Id: " +
admin_id + " updated.");
} else {
System.out.println("Admin Violations for Admin_Id: " +
admin_id + " failed.");
}
} else {
// CHECK IF RECORD EXISTS
query = "SELECT * FROM users WHERE u_id=?";
pst = con.prepareStatement(query);
pst.setInt(1, userid);
ResultSet rs = pst.executeQuery();
if (!rs.next()) {
session.setAttribute("status", "Error: User ID not
found.");
} else {
// UPDATE USER RECORD
query = "UPDATE users SET u_tokens = u_tokens" +
(action.equals("add") ? " + " : " - ") + "? WHERE u_id = ?";
pst = con.prepareStatement(query);
pst.setInt(1, tokens);
pst.setInt(2, userid);
if (rowCount > 0) {
session.setAttribute("status", "Success: Record
updated!");
} else {
session.setAttribute("status", "Error: Failed to
update record.");
}
181
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
response.sendRedirect("./adminElements/token_mgmt.jsp");
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
TableMgmtServlet.java:
This servlet gets called when submitting the Table Form in the “table_mgmt.jsp”
page. The staff / admin can perform updatation, deletion and addition of tables. Once
the query is done processing by the database, an appropriate message is sent to the
user-interface.
package com.onlinecafehub.admin;
182
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
import com.onlinecafehub.config.Config;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* Servlet implementation class TableMgmtServlet
*/
@WebServlet("/tablemgmt")
public class TableMgmtServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
int admin_id =
Integer.parseInt(session.getAttribute("id").toString());
183
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
try {
session.setAttribute("status", null);
Class.forName(Config.getMySqlDriver());
con = DriverManager.getConnection(url, user, pass);
if (rowCount > 0) {
session.setAttribute("status", "Success: Table added
successfully!");
} else {
session.setAttribute("status", "Error: Failed to connect
to MySQL.");
}
if
(!session.getAttribute("status").toString().contains("Error")) {
query = "SELECT * FROM tables";
pst = con.prepareStatement(query);
ResultSet rs = pst.executeQuery();
184
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
ResultSet rs = pst.executeQuery();
if (!rs.next()) {
session.setAttribute("status", "Error: Table ID not
found.");
} else {
// UPDATE TABLE RECORD
query = "UPDATE tables SET chairs=?,available=?-inuse
WHERE id=?";
pst = con.prepareStatement(query);
pst.setInt(1, chairs);
pst.setInt(2, chairs);
pst.setInt(3, tableid);
185
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
if (rowCount > 0) {
session.setAttribute("status", "Success: Record
updated!");
} else {
session.setAttribute("status", "Error: Failed to
update record.");
}
}
ResultSet rs = pst.executeQuery();
if (!rs.next()) {
session.setAttribute("status", "Error: Table ID not
found.");
} else {
// DELETE TABLE RECORD
query = "DELETE FROM tables WHERE id=?";
pst = con.prepareStatement(query);
186
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
pst.setInt(1, tableid);
if (rowCount > 0) {
session.setAttribute("status", "Success: Record
deleted!");
} else {
session.setAttribute("status", "Error: Failed to
delete record.");
}
}
response.sendRedirect("./adminElements/table_mgmt.jsp");
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
187
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
UserMgmtServlet.java:
This servlet gets called when submitting the User Form in the “user_mgmt.jsp” page.
table. If an admin is doing the change, banning or unbanning users with reason, the
database processes the query and sends back appropriate message to the user-interface.
package com.onlinecafehub.admin;
import com.onlinecafehub.config.Config;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* Servlet implementation class UserMgmtServlet
*/
@WebServlet("/usermgmt")
public class UserMgmtServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
188
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
if (session.getAttribute("privilege") == null ||
session.getAttribute("id") == null ) {
dispatcher.forward(request, response);
return;
}
int privilege =
Integer.parseInt(session.getAttribute("privilege").toString());
int admin_id =
Integer.parseInt(session.getAttribute("id").toString());
Boolean isAuthorized = privilege == 1 ? true : false;
try {
session.setAttribute("status", null);
Class.forName(Config.getMySqlDriver());
con = DriverManager.getConnection(url, user, pass);
189
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
if (rowCount > 0) {
session.setAttribute("status", "Success: Unauthorized
access recorded.");
} else {
session.setAttribute("status", "Error: Failed to connect
to MySQL.");
}
if (pst.executeUpdate() > 0) {
System.out.println("Admin Violations for Admin_Id: " +
admin_id + " updated.");
} else {
System.out.println("Admin Violations for Admin_Id: " +
admin_id + " failed.");
}
} else {
// CHECK IF RECORD EXISTS
query = "SELECT * FROM users WHERE u_id=?";
pst = con.prepareStatement(query);
pst.setInt(1, userid);
ResultSet rs = pst.executeQuery();
if (!rs.next()) {
session.setAttribute("status", "Error: User ID not
found.");
} else {
// UPDATE USER RECORD
query = "UPDATE users SET banned=" +
(action.equals("ban") ? "'true'" : "'false'") + " WHERE u_id = ?";
pst = con.prepareStatement(query);
pst.setInt(1, userid);
190
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
if (rowCount > 0) {
session.setAttribute("status", "Success: Record
updated!");
} else {
session.setAttribute("status", "Error: Failed to
update record.");
}
response.sendRedirect("./adminElements/user_mgmt.jsp");
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
191
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
WEB.XML FILE
The web.xml file serves as a central configuration file for the web application and
defines the structure and behavior of the application within the web server
parameters for servlets and filters, initialization parameters for listeners, security
By editing the web.xml file, we can customize the behavior of the web application and
a crucial role in defining how the web application is deployed and executed within a
192
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<display-name>RegistrationServlet</display-name>
<servlet-name>RegistrationServlet</servlet-name>
<servlet-
class>com.onlinecafehub.registration.RegistrationServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RegistrationServlet</servlet-name>
<url-pattern>/RegistrationServlet</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>LoginServlet</display-name>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>com.onlinecafehub.registration.LoginServlet</servlet-
class>
</servlet>
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/LoginServlet</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>LogoutServlet</display-name>
<servlet-name>LogoutServlet</servlet-name>
<servlet-class>com.onlinecafehub.registration.LogoutServlet</servlet-
class>
</servlet>
<servlet-mapping>
<servlet-name>LogoutServlet</servlet-name>
<url-pattern>/LogoutServlet</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>TokenMgmtServlet</display-name>
<servlet-name>TokenMgmtServlet</servlet-name>
<servlet-class>com.onlinecafehub.admin.TokenMgmtServlet</servlet-class>
193
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
</servlet>
<servlet-mapping>
<servlet-name>TokenMgmtServlet</servlet-name>
<url-pattern>/TokenMgmtServlet</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>TableMgmtServlet</display-name>
<servlet-name>TableMgmtServlet</servlet-name>
<servlet-class>com.onlinecafehub.admin.TableMgmtServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TableMgmtServlet</servlet-name>
<url-pattern>/TableMgmtServlet</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>AdminRouteServlet</display-name>
<servlet-name>AdminRouteServlet</servlet-name>
<servlet-class>com.onlinecafehub.admin.AdminRouteServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AdminRouteServlet</servlet-name>
<url-pattern>/AdminRouteServlet</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>UserMgmtServlet</display-name>
<servlet-name>UserMgmtServlet</servlet-name>
<servlet-class>com.onlinecafehub.admin.UserMgmtServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UserMgmtServlet</servlet-name>
<url-pattern>/UserMgmtServlet</url-pattern>
</servlet-mapping>
<servlet>
194
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<description></description>
<display-name>ReportServlet</display-name>
<servlet-name>ReportServlet</servlet-name>
<servlet-class>com.onlinecafehub.user.ReportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ReportServlet</servlet-name>
<url-pattern>/ReportServlet</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>FeedbackServlet</display-name>
<servlet-name>FeedbackServlet</servlet-name>
<servlet-class>com.onlinecafehub.user.FeedbackServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FeedbackServlet</servlet-name>
<url-pattern>/FeedbackServlet</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>UpdateServlet</display-name>
<servlet-name>UpdateServlet</servlet-name>
<servlet-class>com.onlinecafehub.user.UpdateServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UpdateServlet</servlet-name>
<url-pattern>/UpdateServlet</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>ContactServlet</display-name>
<servlet-name>ContactServlet</servlet-name>
<servlet-class>com.onlinecafehub.user.ContactServlet</servlet-class>
</servlet>
<servlet-mapping>
195
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
<servlet-name>ContactServlet</servlet-name>
<url-pattern>/ContactServlet</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>ChatServlet</display-name>
<servlet-name>ChatServlet</servlet-name>
<servlet-class>com.onlinecafehub.user.ChatServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ChatServlet</servlet-name>
<url-pattern>/ChatServlet</url-pattern>
</servlet-mapping>
</web-app>
196
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
S EVERAL error handling and parameter passing techniques are used to ensure the
• The code uses try-catch and conditional statements to handle both server-side
client-side errors (invalid input field values, accessing pages that are privileged,
etc). And the web app displays appropriate error and success messages to inform
the user.
• The servlets defined uses the POST method to retrive data from the form
pages on user-interface.
• To prevent SQL injections into the database while updating or inserting into
• The code also utilises JavaScript to ensure empty or too much data than what
197
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
7. Testing
7.1 Introduction to The Testing Phase
T ESTING phase of the Online Café Hub project played a crucial role in ensuring
the quality, reliability, and robustness of the application. This section provides
the testing phase. The primary objectives of the testing phase were as follows:
Online Café Hub web application are working as intended and meet the specified
198
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
function, and module underwent unit testing. This involved creating test cases
ensuring their accuracy and functionality. The purpose of unit testing was to
potential issues and bugs were identified early, allowing for prompt debugging
and ensuring the overall quality and stability of the web application.
• Integration Testing: Following the completion of unit testing, the next phase
within the system. The primary goal of integration testing was to detect and
address any potential issues that may arise during the integration process. By
199
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• System Testing: System testing was performed on the complete Online Café
Hub web application to assess its adherence to the specified requirements. This
testing was to verify the overall functionality, usability, and performance of the
system testing ensured that it met the intended objectives and provided a
users, UAT aimed to identify any potential usability or functionality gaps and
ensure that the application aligns with their expectations. The feedback
200
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
obtained from UAT played a crucial role in refining the application and making
• Test Steps:
• Expected Result:
2. Test Case: Verify user registration functionality with duplicate email and/or
phone number.
• Test Steps:
201
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• Expected Result:
Login page.
• Test Steps:
• Expected Result:
➢ User is signed in and they are redirected to the Café page or the
• Test Steps:
• Expected Result:
202
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• Test Steps:
• Expected Result:
• Test Steps:
• Expected Result:
• Test Steps:
203
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• Expected Result:
• Test Steps:
• Expected Result:
• Test Steps:
• Expected Result:
204
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• Test Steps:
• Expected Result:
11. Test Case: Verify updating phone number with valid credentials.
• Test Steps:
• Expected Result:
12. Test Case: Verify updating phone number with invalid credentials.
• Test Steps:
205
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• Expected Result:
• Test Steps:
• Expected Result:
• Test Steps:
• Expected Result:
206
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• Test Steps:
• Expected Result:
• Test Steps:
• Expected Result:
• Test Steps:
207
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
button.
• Expected Result:
• Test Steps:
button.
• Expected Result:
• Test Steps:
208
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• Expected Result:
• Test Steps:
• Expected Result:
209
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
210
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
211
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
212
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
213
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
214
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
215
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
216
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
217
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
218
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
219
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
220
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
221
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
222
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
223
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
224
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
9. Implementation of Security
I N this section, we will discuss the various security measures implemented in the
software developed for Online Café Hub. The following subsections outline the key
Email, Phone Number and Password: Users are required to register with a unique
email address, phone number and password. The system stores the password securely
PasswordHashing.java:
package com.onlinecafehub.authentication;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.spec.InvalidKeySpecException;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
225
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
226
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
The PasswordHashing class is responsible for providing methods to hash and verify
passwords using the PBKDF2 algorithm with HMAC-SHA256. This class implements
password hashing techniques to enhance the security of storing and verifying passwords
in a system.
The hashPassword method takes a password and a salt as input and generates a hashed
password. It uses the PBKDF2 algorithm with HMAC-SHA256 to perform the hashing.
The iterations variable determines the number of iterations performed in the hashing
process, while the keyLength defines the length of the generated key. The method
returns the hashed password as a combination of the salt and the hash itself.
The generateSalt method generates a random salt using a secure random number
generator. The salt is a randomly generated value used to add uniqueness and
complexity to the hashing process. It is crucial for generating different hashes for the
password. It takes the entered password and the stored password as input and performs
the verification. It extracts the salt from the stored password and uses it to hash the
entered password. The method then compares the hashed entered password with the
The hexToBytes and bytesToHex methods are utility methods used to convert byte
227
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
maintain user authentication throughout the user's session. Secure session identifiers
are generated and validated for each user, preventing unauthorized access to sensitive
information.
Transport Layer Security (TLS): All communication between the client and server
occurs over secure HTTPS connections using TLS encryption. This ensures that data
Password Encryption: As mentioned earlier, user passwords are not stored in plain
text. Instead, they are securely hashed using the PBKDF2 algorithm with HMAC-
SHA256 hashing technique. This ensures that even if the password hashes are obtained
passwords.
228
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
A
PPROPRIATE measures are taken to ensure the secure transmission of data
from the client to the server. The following techniques have been implemented:
HTTPS Protocol: The software employs the HTTPS protocol to encrypt data
transmission between the client's browser and the server. This provides an additional
layer of security by encrypting all data exchanged between the client and server,
Input Validation: Client-side and server-side input validation techniques have been
cross-site scripting (XSS) attacks. Input from users is carefully validated and sanitized
before processing to ensure data integrity and prevent malicious code injection.
229
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
• Responsiveness: The website looks the best in larger screen sizes, like desktop,
laptop and pads. For smaller screen sizes the UI gets mushed.
compatible with modern web browsers and devices. However, as the technology
evolves, it might face compatibility issues with older browsers and outdated
hardware.
• Payment Facility: The project as of now does not include any payment
facility inbuilt, it relies on third-party sites like Zomato and Swiggy to take care
• Token Utilization: The tokens that are given to users, does not have any
benefits as of now.
230
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
This project is designed and developed such that modifications can be done easily
The project will be further developed to provide more features like mobile support,
Load balancers will be implemented to ensure large number of requests are handled
Security module will be modified to ensure user data security to the maximum
quality.
Better menu system will be added with better token usage. Additional changes like
231
Enrollment Number: 2003722459 Name: DEBALOY CHATTERJEE
Project Report for BCSP–064 Online Café Hub
12. Bibliography
12.1 Websites
• www.javatpoint.com
• www.tutorialspoint.com
12.2 Books
• Joel Murach & Andrea Steelman: Murach's Java Servlets and JSP (3rd
• Kathy Sierra, Bryan Basham & Bert Bates: Head First Servlets and JSP (2nd
• Kathy Sierra, Trisha Gee & Bert Bates: Head First Java (3rd Edition), 20th
May 2022
• IGNOU blocks
232