Hi all,
forgive me but I am a little knew to Servlets! Could someone clarify this
for me:
I have a shopping cart servlet that accepts requests from JSP pages. The
servlet creates a shopping cart class and gets data entered into the JSP
page from the request object and populates the shopping cart object (code
fragment below).
Now, will the shopping cart servlet put data into the shopping cart class
that is related to the individual session?? I believe so - I believe that
some how the servlet knows what shopping cart class is related to that
customers request - is this true?? - session meaning a user working with the
shopping cart functionality in a web browser.
Best Regards
Marc
private void performTask(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse res)throws ServletException,
IOException
{
javax.servlet.http.HttpSession session = request.getSession(true);
boolean logWriteSuccess = true;
try{
//ITEMS FOR ORDER
//check to see if there is an existing ShoppingCart class
ShoppingCart aShoppingCart = (ShoppingCart)
session.getValue("ShoppingCart");
//if not create one
if(aShoppingCart == null){
aShoppingCart = createNewShoppingCart(request);
}
//now is it to remove an item or is it to add item(s)?
String action = getParameter(request, "action", true, true,
true, null);
if(action.equals("ADD")){
addItemsToShoppingCart(request,aShoppingCart);
session.putValue("ShoppingCart",aShoppingCart);
logWriteSuccess =
writeTransactionToLog(buildLogMessage(request,session.getId(),"ADD"));
callPageNamed(getParameter(request,
"NelsonShoppingCartTotal", true, true, false, "NelsonShoppingCartTotal"),
request, res);
}else if(action.equals("DELETE")){
........
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html