Lab ShoppingCartMVC2
Lab ShoppingCartMVC2
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