View Full Version : Please HElp Me!!! Thanks... Urgent...

07-01-2005, 04:19 AM
Hi guys!!! Need your help urgently. Need to present later... Thanks a lot.\
<!-- Filename: ShoppingCart.jsp original version -->
<%@ page errorPage="errorpage.jsp" %>
<%@ page import="java.util.*" %>

<!-- Instantiate the Counter bean with an id of "counter" -->
<jsp:useBean id="cart" scope="session" class="database.ShoppingCart" />
String id = request.getParameter("itemID");
String buttonPressed = request.getParameter("Submit");
String updatePressed = request.getParameter("input");
String quantity = request.getParameter("Sum");

if (updatePressed!=null){
cart.updateQuantity(id, Integer.parseInt(quantity));

if (buttonPressed!=null){



<title>Shopping Cart Contents</title>
<table width="300" border="1" cellspacing="0"
cellpadding="2" border="0">
<caption><b>Shopping Cart Contents</b></caption>
<body bgcolor= #CCCFFFF>
<th>Remove An Item</th>
<th>Update Quantity</th>

Enumeration enum = cart.getEnumeration();
String[] tmpItem;
int numOfItems = 0;
// Iterate over the cart
while (enum.hasMoreElements()) {
<form action="ShoppingCart.jsp" method="post">
tmpItem = (String[])enum.nextElement();
numOfItems += Integer.parseInt(tmpItem[3]);
%> <tr>
<td><%=tmpItem[1] %></td>
<td align="center">$<%=tmpItem[2] %></td>
<td align="center"><%=tmpItem[3] %></td>
<td><input type="submit" name="Submit" value="Remove"></td>
<td><input type="text" name="Sum"><input type="Submit" name="input" value="update"></td>
<input type="hidden" name="itemID" value= "<%=tmpItem[0] %>" >


</font><font color = "#000FFF">
<br> You are buying <%=cart.getNumOfItems() %> items.</br>
<br> Total coat is $<%=cart.getCost() %> </br>
<p align = "center">You have to pay $<%=cart.getCost() %>
</font><font color = "#CC0099">
<a href="AddToShoppingCart.jsp">Back to Catalog</a>

Can tell me briefly wat does this means specially those in bold cox dun understand...

07-01-2005, 04:59 AM
Please post in the correct cateogry. From what I can tell this is JSP (definitely not HTML either way). Moving thread to Other Category, since we don't have a JSP forum yet.

07-01-2005, 07:33 AM
Enumeration enum = cart.getEnumeration(); // Enumeration: an object which assigns each item a number. cart.getEnumeration() can be expected to return an enumeration consisting of all the items in the cart.
String[] tmpItem; // Array of Strings
int numOfItems = 0;
// Iterate over the cart
while (enum.hasMoreElements()) { // As long as we haven't reached the last item,
<form action="ShoppingCart.jsp" method="post"> // open a form,
tmpItem = (String[])enum.nextElement(); // assign the next element of enum to tmpItem, casting it into an array of Strings first,
numOfItems += Integer.parseInt(tmpItem[3]); // then increase the total number of items by the integer stored in the third string in the String array (presumably quantity).