0% found this document useful (0 votes)
14 views15 pages

Lab ShoppingCartMVC2

This document outlines the steps to build a Java web application for online shopping using MVC2 model. It involves creating servlets and JSP pages to display products, add items to a shopping cart, and save the cart to session or cookie. Model classes like Book and CartItem are developed to represent application data. Controllers pass data between pages and components using request dispatchers. The completed application is tested by running it to verify all shopping functions.

Uploaded by

trancaodiepnct
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views15 pages

Lab ShoppingCartMVC2

This document outlines the steps to build a Java web application for online shopping using MVC2 model. It involves creating servlets and JSP pages to display products, add items to a shopping cart, and save the cart to session or cookie. Model classes like Book and CartItem are developed to represent application data. Controllers pass data between pages and components using request dispatchers. The completed application is tested by running it to verify all shopping functions.

Uploaded by

trancaodiepnct
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Building an Java Web Application

Requirements
Create an Java web application (using HTML, Servlets, and JSP ) by MVC2 Model to
perform functions as shopping online.

Lab Objectives
In this lab, you will be:
▪ Create Java web project by MVC2 Model
▪ Create the web pages by HTML, and JSP
▪ Apply passing data from HTML to Servlet by GET and POST method
▪ Apply RequestDispatcher to pass data between Servlets
▪ Performs save the shopping cart to the Session and Cookie
▪ Run the project and test the functions of the project

1|Page
Step 01. Create a Java Web App named Lab05_ShoppingCart is structured
as follows:

Step 02. Write codes for the classes in the Models.DTO and Models.DAO
packages are as follows:
2.1. Models.Entities package
• Book.java

2|Page
• CartItem.java

3|Page
2.2. Models.DAO package
• BookDAO.java

Step 03. Write codes for the classes in the Controllers.Book package as
follows:
• ViewBookController.java

4|Page
• BookController.java

5|Page
Step 04. Write codes for the classes in the Controllers.Cart package is as
follows:
• AddCartController.java

6|Page
• ViewCartController.java

• RemoveCartController.java

7|Page
• UpdateCartController.java

8|Page
• CartUtil.java

9|Page
• SaveCartController.java

10 | P a g e
• CartController.java

11 | P a g e
Step 05. Write codes for the web pages as follows:
• Index.html page

• ViewBooks.jsp page

12 | P a g e
• ViewCart.jsp page

13 | P a g e
14 | P a g e
Step 05. Right-click on the Lab05_ShoppingCart project, select Run to run the
web app then test all functions.

15 | P a g e

You might also like