A Java web app (Servlets + JSP) to add products and view them in a clean Bootstrap UI
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.
- 🏠 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
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
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
git clone https://github.com/Gaganajain/java_project.git
cd java_project/product-information-application
mvn clean packageCopy 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/
- File → Import → Existing Projects into Workspace and choose
product-information-application. - Add an Apache Tomcat 9 server in the Servers view.
- Right-click the project → Run As → Run on Server.
| 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 |
- 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
Gagana Jain A · GitHub
⭐ If you found this useful, consider giving the repo a star!