Hi all,
Question - how can I provide functionality to my Shopping Cart Servlet that
both handles requests from cookie enabled web browsers and non-cookie
enabled web browsers?

Noting that my JSP pages do not call other pages but
calls the Shopping Cart Servlet.  The Shopping Cart servlet in turn gets the
JSP page data and does some stuff with it, stores it back into the session
object and then calls another JSP page.  I have included some code blocks
from both my Servlet and JSP pages.

Marc


Code extract from Shopping Cart Servlet
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

String action = getParameter(request, "action", true, true, true, null);

if(action.equals("ADD")){
        addItemsToShoppingCart(request,aShoppingCart);
        session.putValue("ShoppingCart",aShoppingCart);
        HttpServiceResponse response = (HttpServiceResponse)res;
        response.callPage("/NelsonShoppingCartTotal.jsp", request);

}else if(action.equals("DELETE")){
        removeSeletedItemFromShoppingCart(request,aShoppingCart);

Code from JSP Page
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

<%
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);

javax.servlet.http.HttpSession session = request.getSession(false);

nelsonshoppingcart.Customer aCustomer = (nelsonshoppingcart.Customer)
session.getValue("Customer");
out.println("<P>To contents are  : " + aCustomer.getUserTo() + "</P>");
%>
<TABLE Border="1" cellpadding="0" width="50%">
<TR>
<TD><B>ISBN Number</B></TD>
<TD><B>Quantity</B></TD>
</TR>

<%
nelsonshoppingcart.ShoppingCart aShoppingCart =
(nelsonshoppingcart.ShoppingCart) session.getValue("ShoppingCart");
java.util.Vector theItemsList =
(java.util.Vector)aShoppingCart.getItemsOrdered();

for(int index=0;index < theItemsList.size();index++){
        nelsonshoppingcart.Item anItem =
(nelsonshoppingcart.Item)theItemsList.elementAt(index);
%>

<TR>
<TD><B><%= anItem.getISBNNumber() %></B></TD>
<TD><B><%= anItem.getISBNQuantity() %></B></TD>
<TD>
        <FORM NAME="deleteForm"
ACTION="servlet/nelsonshoppingcart.NelsonShoppingCartServlet" METHOD="POST">
        <INPUT TYPE="submit" value="Delete">
        <INPUT TYPE="hidden" NAME="delindex" VALUE='<%= index %>'>
        <INPUT TYPE="hidden" NAME="action" VALUE="DELETE">
        <INPUT TYPE="hidden" NAME="formName" VALUE="SHOPPINGCARTTOTAL">
        </FORM></TD>

</TR>
<% } %>
</TABLE>

___________________________________________________________________________
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

Reply via email to