[Burichan] [Futaba] [Gurochan] [Photon] - [Home]

[Return]
Reply mode
Name
Link
Subject
Comment
File
Password (for post and file deletion)
Leave empty (spam trap):
  • Supported file types are: GIF, JPG, PNG
  • Maximum file size allowed is 1000 KB.
  • Images greater than 200x200 pixels will be thumbnailed.

>> No.2  

ArrayList theCart = new ArrayList();

    if (session.getAttribute("cart") != null){
theCart = (ArrayList)session.getAttribute("cart");
}
beans.ProductFormBean theBean = (ProductFormBean)form;
managers.ProductManager manager = new managers.ProductManager();
    if (theBean.getProductId() == 0) {
request.setAttribute("message", "Product Id is required");
nextPage = mapping.findForward("failure");
}
else if (theBean.getQuantity() == 0) {
request.setAttribute("message", "Quantity is required");
nextPage = mapping.findForward("failure");
}
    else{
try{
theBean = manager.find(theBean);
if (theBean == null){
nextPage = mapping.findForward("failure");
request.setAttribute("message", "Error locating product");
}
else{
request.setAttribute("message", "Product Added to Cart");
theCart.add(theBean);
theCart.add(theBean);
//request.setAttribute("cart", theCart);
session.setAttribute("cart",theCart);

nextPage = mapping.findForward("success");
}
}
catch (Exception e){
request.setAttribute("message", e+" "+"exception error");
nextPage = mapping.findForward("failure");
}

// request.setAttribute("cart", theBean);

    }
return nextPage;


Delete Post []
Password