Log in

View Full Version : Please hELP ME!!!



huisoonsg
06-30-2005, 02:19 PM
Hi to all, can anyone who knows what the following is about pls tell me. Thanks you very much!
<!-- 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(id!=null){
if (updatePressed!=null){
cart.updateQuantity(id, Integer.parseInt(quantity));
}

if (buttonPressed!=null){

cart.removeItem(id);
}
}

%>

Twey
06-30-2005, 06:08 PM
An interface to a server-side shopping cart program in Java Server Pages (JSP) - a way to reference Java classes and use their output from within a page.
String id to ("Sum"); gets various parameters and assigns them to variables.
If updatePressed exists (presumably updatePressed is sent to the page by form or another script when an "update" button is pressed) assume the button was clicked and call the appropriate method in the (previously referenced) Java object ("cart").
buttonPressed appears to be much the same as updatePressed, but from a "Delete" button, and again, the method is called in the server-side Java object to delete the item from wherever it's being stored.