How ronalhung05/bookstorewebsite-jsp-servlet-java works
Project Type and Purpose
• This is a Java-based web application built using pure JSP and Servlets. The README confirms it’s a “Website bán sách” (book selling website) with detailed documentation and tests.
• The application is structured following a typical MVC architecture where presentation is handled by JSPs, control flows via Servlet-based controllers, and business logic resides in services and DAOs.
Analyzing the File Structure
• Top-Level Directories and Files:
– WebContent: Contains web assets, configuration (web.xml), JSP pages, CSS, JavaScript, images, and various external libraries.
– src: Contains the backend Java code organized into packages for controllers (both admin and frontend), services, DAOs, and entities.
– Resources and configuration files like pom.xml (indicating Maven usage), hibernate.cfg.xml, and persistence.xml suggest the integration of Hibernate (or JPA) as the persistence layer.
• The structure shows a clear separation between the admin area (located under WebContent/admin and corresponding backend controllers in src/com/bookstore/controller/admin) and the frontend area (located under WebContent/frontend and corresponding src controllers).
Main Components
a. Client Layer:
– End-User web browsers accessing the system.
– Separate paths for administrative users (admin interface) and regular customers (frontend interface).
b. Web Server / Application Server:
– A container (such as Apache Tomcat) serving the application.
– Handles HTTP requests forwarded to the appropriate servlets.
c. Controller Layer (Servlets):
– Admin Controllers: Manage operations such as managing books, categories, orders, customers, reviews, and users.
– Frontend Controllers: Handle homepage, book browsing, shopping cart functionalities, checkout processes, customer login/registration, and review submissions.
– Include filters (e.g., AdminLoginFilter, CustomerLoginFilter, CommonFilter) for authentication and request preprocessing.
d. Service Layer:
– Contains business logic classes (e.g., BookServices, CategoryServices, CustomerServices, PaymentServices, etc.) that process data before interacting with the database.
– Acts as an intermediary between controllers and the data access layer.
e. Data Access Layer:
– DAO classes (e.g., BookDAO, CategoryDAO, CustomerDAO, etc.) responsible for CRUD operations.
– Entity classes (e.g., Book, Category, Customer, OrderDetail, etc.) that model the persistent data.
– Hibernate configuration files (hibernate.cfg.xml and hibernate.reveng.xml) and JPA setup (persistence.xml), reflecting ORM usage.
f. Presentation Layer:
– JSP Pages segmented into admin and frontend directories.
– Common components shared across pages (header, footer, message components).
g. External Libraries & Assets:
– Libraries for UI components (Bootstrap, jQuery, Slick Carousel, etc.) and other utilities (charting libraries, inputmask, etc.).
– These resources are managed and deployed from the WebContent/libs directory.
Architectural Patterns and Design Principles
• MVC Pattern: The design clearly splits concerns into views (JSPs), controllers (Servlets), and model (services/DAO/entities).
• Layered Architecture: The separation into presentation, controller, service, and persistence layers should be clearly depicted.
• Use of Filters: Authentication and common request processing are applied via servlet filters.
• Maven-Based Build: The project uses Maven for dependency management and build processes.
Summary
This approach should provide a comprehensive depiction of the system, reflecting its multi-tiered design and ensuring that all essential architectural elements are captured clearly.