posted 22 years ago
hello,
i have made a simple shopping cart which goes through the
following stage:
1st stage:
// Additions to the shopping cart
HttpSession clientSession = request.getSession( true );
ShoppingCart vBasket = (ShoppingCart)clientSession.getValue("thecart");
if ( vBasket == null ){
System.out.println("NO CART");
vBasket = new ShoppingCart();
clientSession.putValue("thecart", vBasket);
}
System.out.println("MADE THE CART");
vBasket.add(the_item);
// at this stage, the items are being added to a hashtable
2nd stage:
HttpSession clientSession = request.getSession( true );
System.out.println("GOT THE SESSION");
ShoppingCart vBasket = (ShoppingCart)clientSession.getValue("thecart");
if ( vBasket == null ){
System.out.println("CART HASN'T BEEN MADE!!");
throw new Exception();
}
// At this stage, the object of the ShoppingCart class still has null value even if in the existing session the ShoppingCart has been made at stage 1. Any idea why this is happening??
thanks
Richard