Skip to content

Latest commit

 

History

History
116 lines (88 loc) · 3.82 KB

README.md

File metadata and controls

116 lines (88 loc) · 3.82 KB

📦 Product Information Application

A Java web app (Servlets + JSP) to add products and view them in a clean Bootstrap UI

Java Servlets JSP Bootstrap Tomcat Maven


📌 Overview

A beginner-friendly Java EE web application that shows the classic request flow: an HTML/JSP form posts data to a Servlet, the servlet validates and stores it, and a JSP page renders the result.

Users can add a product with a name, code and price, and see every saved product in a table.

✨ Features

  • 🏠 Landing page with quick links
  • 📝 Add Product form with client-side and server-side validation
  • 💾 SaveServlet (/saveproduct) validates input and stores products in application scope
  • 📋 ViewServlet (/viewproducts) lists all products in a responsive table
  • 🛡️ Output escaping on the view page to prevent HTML injection
  • 📱 Responsive layout with Bootstrap 5

🔄 Request Flow

sequenceDiagram
    participant B as Browser
    participant A as AddProduct.jsp
    participant S as SaveServlet
    participant V as ViewServlet
    participant J as ViewProducts.jsp
    B->>A: GET AddProduct.jsp
    B->>S: POST /saveproduct (name, code, price)
    alt invalid input
        S-->>A: forward with error message
    else valid
        S->>S: store Product in ServletContext
        S-->>B: redirect /viewproducts
        B->>V: GET /viewproducts
        V->>J: forward product list
        J-->>B: HTML table
    end
Loading

📂 Project Structure

java_project/
└── product-information-application/
    ├── pom.xml
    └── src/main/
        ├── java/com/bce/product/
        │   ├── model/Product.java          # Product name, code, price
        │   └── servlets/
        │       ├── SaveServlet.java        # POST /saveproduct
        │       └── ViewServlet.java        # GET  /viewproducts
        └── webapp/
            ├── index.html                  # Landing page
            ├── AddProduct.jsp              # Add form
            ├── ViewProducts.jsp            # Product table
            └── nav.jspf                    # Shared navbar

🚀 Getting Started

Option 1: Maven + Tomcat

git clone https://github.com/Gaganajain/java_project.git
cd java_project/product-information-application
mvn clean package

Copy target/product-information-application.war into Tomcat's webapps/ folder, start Tomcat (version 9, which uses the javax.servlet API) and open:

http://localhost:8080/product-information-application/

Option 2: Eclipse IDE

  1. File → Import → Existing Projects into Workspace and choose product-information-application.
  2. Add an Apache Tomcat 9 server in the Servers view.
  3. Right-click the project → Run As → Run on Server.

🛠️ Tech Stack

Layer Technology
Backend Java Servlets (Servlet API 4.0)
View JSP, Bootstrap 5
Build Maven (WAR packaging) / Eclipse Dynamic Web Project
Server Apache Tomcat 9

🔮 Future Improvements

  • Save products in MySQL with JDBC instead of memory
  • Edit and delete products
  • Search and sort the product table
  • Switch to JSTL tags in the JSP pages

👩‍💻 Author

Gagana Jain A · GitHub

⭐ If you found this useful, consider giving the repo a star!