Hi all,
I would like to add on my last message:
I have a Shopping Cart Servlet and is called by my Shopping Cart JSP. The
process is as follows:
1.The user selects the items he/she would like to add to the shopping cart
and clicks the "Add To Shopping Cart" button.
2.The Shopping Cart Servlet is called in the form actions parameter.
3.The shopping Cart Servlet knows that this is an Add request to it adds the
select items to the Shopping Cart class.
4.The Shopping Cart class is placed within the Session object.
5.The Shopping Cart Servlet then calls the Shopping Cart Total JSP via the
callPage() method.
6.The Shopping Cart Total JSP page gets a hold on the Shopping Cart class
and displays the results. If the user wishes to continue the use selects
the "Continue Shopping" button.
7.The shopping Cart Servlet is called since the form actions parameter is
the Shopping Cart Servlet. The Servlet knows that it must call the Shopping
Cart JSP...and so on...
Now this functionality works with cookies enabled but without cookies it
does not. I have attempted to use the response.encodeUrl() method in the
callPage method and also attempted the response.encodeRedirectUrl (in
callPage) method both do not work (eg
response.callPage(response.encodeUrl("/NelsonShoppingCartTotal.jsp"),
request);)- infact I get errors from the web browser - Bad Request 400. I
have enabled URL rewriting in WebSphere as well.
Question - how can I provide functionality to by 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
call the Shopping Cart Servlet. I have included some code blocks from both
my Servlet and JSP pages.
Thanks for reading this!
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: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets