<%-- This JSP displays details of the products added to the cart. The details includes the name of the product, quantity, base price, discount and total price of each line item. It also displays subtotal, taxes and grand total of the entire cart. Customer has provision to modify the quantities, order the contents and clear the cart. --%> Jasmine's Shopping Cart page <%@ page import="examples.shop.impl.entity.Product" %> <%@ page import="examples.shop.impl.entity.LineItem" %> <%@ page import="java.util.List" %> <%@ page import="java.util.Iterator" %> <%@ page import="java.text.NumberFormat" %>
<% // get the lineItems from the request object and displays in a table format. List lineItems = (List)request.getAttribute("lineItems"); double subTotal=((Double)request.getAttribute("subTotal")).doubleValue(); double taxes=((Double)request.getAttribute("taxes")).doubleValue(); double taxRate=((Double)request.getAttribute("taxRate")).doubleValue(); double total=((Double)request.getAttribute("total")).doubleValue(); for(Iterator iter = lineItems.iterator(); iter.hasNext();) { LineItem li = iter.next(); int quantity = li.getQuantity(); double discount = li.getDiscount(); Product product = li.getProduct(); String productID = product.getProductID(); double basePrice = product.getBasePrice(); %> <% } %>
Name Quantity Individual Base Price Discount Total Price
<%=product.getName()%> <%=basePrice%> <%=discount%> <%=basePrice*quantity-discount%>

Subtotal: <%=subTotal%>
Sales Tax: <%=taxes%>(<%=taxRate%>)%
Grand Total: <%=total%>

See the Catalog