Java Reference
In-Depth Information
L ISTING 20.6
Continued
<td width=”75” valign=”top”><%@ include file=”navigation.jsp” %></td>
<td valign=”top”>
<table cellspacing=”0” cellpadding=”2” border=”0” width=”600”>
<%
Object[] movies = (Object[])request.getAttribute(“movies”);
for ( int x = 0; x < movies.length; x++ ) {
HashMap movie = (HashMap)movies[x];
out.println(“<tr><td>” + movie.get(“title_name”) + “</td>” +
“<td>” + movie.get(“price”) + “</td>” +
“<td>” + movie.get(“quantity”) +
“<td><a href=/catalog/servlet/Controller?service=AddToCart” +
“&title_id=” + movie.get(“title_id”) +
“&target=/ListShoppingCart.jsp>Buy</a></td></tr>”);
}
%>
</table>
</td>
</tr>
</table>
</body>
</html>
Shopping Cart View
The Shopping Cart view will be represented by the file ListShoppingCart.jsp . It will
display the current contents of the shopping cart. An image of the Shopping Cart view is in
Figure 20.6.
The source for the Shopping Cart view is in Listing 20.7.
L ISTING 20.7
ListShoppingCart.jsp
<%@ page errorPage=”errorpage.jsp” %>
<%@ page import=”java.util.*” %>
<!-- Instantiate the Counter bean with an id of “counter” -->
<jsp:useBean id=”cart” scope=”session” class=”ShoppingCart” />
<html>
<head>
<title>Shopping Cart Contents</title>
</head>
<body bgcolor=”#FFFFFF”>
<table width=”100%” border=”0”>
<tr>
20
 
Search WWH ::




Custom Search