| Shopping cart application using struts Hi,
I am a Java begininer. I am doing an assignment on shopping cart using Struts framework.
I have a arraylist in my session.
How can i check the size of this arraylist in a jsp-page (with the
jstl taglib)
I want to display a number each time the array size increases.
Here I have pasted the code of the action class I created :
Hashtable item = new Hashtable();
item.put("brand", request.getParameter("brand"));
item.put("color", request.getParameter("color"));
item.put("size", request.getParameter("size"));
item.put("price", request.getParameter("price"));
item.put("shipping", request.getParameter("shipping"));
if (session.getAttribute("cart") == null) {
ArrayList cart = new ArrayList();
cart.add(item);
session.setAttribute("cart", cart);
}
else {
ArrayList cartFromSession = (ArrayList) session.getAttribute("cart");
cartFromSession.add(item);
session.setAttribute("cart", cartFromSession);
}
} catch (Exception e) {
System.out.println("Exception occured");
return mapping.findForward("Failure");
}
return mapping.findForward("SUCCESS");
}
}
How do I check the size of an arraylist in a jsp page with jstl tags. Any help would be greatly appreciated.
Thanks!
Last edited by santhini; 05-16-2005 at 07:01 PM.
|