Java/JSP/Shopping Cart
Jsp Session Cart
<source lang="java">
//File: carts.html <html>
<head>
<title>carts</title>
</head>
<body bgcolor="white">
<form type=POST action=carts.jsp>
Please enter item to add or remove:
Add Item:
<SELECT NAME="item">
<OPTION>Beavis & Butt-head Video collection
<OPTION>X-files movie
<OPTION>Twin peaks tapes
<OPTION>NIN CD
<OPTION>JSP Book
<OPTION>Concert tickets
<OPTION>Love life
<OPTION>Switch blade
<OPTION>Rex, Rugs & Rock n" Roll
</SELECT>
<INPUT TYPE=submit name="submit" value="add">
<INPUT TYPE=submit name="submit" value="remove">
</form>
</body> </html> ///////////////////////////////////////////////////////////////////////// //File: carts.jsp <html>
<jsp:useBean id="cart" scope="session" class="sessions.DummyCart" /> <jsp:setProperty name="cart" property="*" /> <%
cart.processRequest(request);
%>
You have the following items in your cart:
-
<%
String[] items = cart.getItems();
for (int i=0; i<items.length; i++) {
%>
- <% out.print(util.HTMLFilter.filter(items[i])); %> <% } %>
<%@ include file ="carts.html" %> </html>
</source>