on line 206, I what to create a link that will direct you to the detail of the chosen items, like in the screenshot
Yes, I know the rules. This is a home and the class is for graduate student and I am an undergraduate. the teacher doesn't render any help whatsoever. check the comment on her rating,the last comment is the class I am taking with her.
http://209.85.165.104/search?q=cache...ient=firefox-a
anyone that feels like giving me a personal assistant can pm me.
Thanks in Advance
Expand|Select|Wrap|Line Numbers
- /*
- * OrderPage.java
- *
- * Created on October 16, 2007, 12:31 PM
- */
- package ITIS5166;
- import java.io.*;
- import javax.servlet.*;
- import javax.servlet.http.*;
- import java.util.*;
- import java.text.*;
- /** Shows all items currently in ShoppingCart. Clients
- * have their own session that keeps track of which
- * ShoppingCart is theirs. If this is their first visit
- * to the order page, a new shopping cart is created.
- * Usually, people come to this page by way of a page
- * showing catalog entries, so this page adds an additional
- * item to the shopping cart. But users can also
- * bookmark this page, access it from their history list,
- * or be sent back to it by clicking on the "Update Order"
- * button after changing the number of items ordered.
- * <P>
- * Taken from Core Servlets and JavaServer Pages 2nd Edition
- * from Prentice Hall and Sun Microsystems Press,
- * http://www.coreservlets.com/.
- * © 2003 Marty Hall; may be freely used or adapted.
- */
- public class ShopCartServletHW3 extends HttpServlet {
- public void doGet(HttpServletRequest request,
- HttpServletResponse response)
- throws ServletException, IOException {
- HttpSession session = request.getSession();
- ShopCartDataHW3 cart;
- synchronized(session) {
- cart = (ShopCartDataHW3)session.getAttribute("ShopCartDataHW3");
- // New visitors get a fresh shopping cart.
- // Previous visitors keep using their existing cart.
- if (cart == null){
- cart = new ShopCartDataHW3();
- session.setAttribute("ShopCartDataHW3", cart);
- }
- String itemID = request.getParameter("itemID");
- if (itemID != null) {
- String numItemsString = request.getParameter("numItems");
- if (numItemsString == null) {
- cart.addItem(itemID);
- } else {
- // If request specified an ID and number, then
- // customers came here via an "Update Order" button
- // after changing the number of items in order.
- // Note that specifying a number of 0 results
- // in item being deleted from cart.
- int numItems;
- try {
- numItems = Integer.parseInt(numItemsString);
- } catch(NumberFormatException nfe) {
- numItems = 1;
- }
- cart.setNumOrdered(itemID, numItems);
- }
- }
- }
- // Whether or not the customer changed the order, show
- // order status.
- String straddress=request.getParameter("address");
- String strshippingtype=request.getParameter("shippingtype");
- String strcardtype=request.getParameter("cardtype");
- String strcardnum=request.getParameter("cardnum");
- String strcardname=request.getParameter("personname");
- response.setContentType("text/html");
- PrintWriter out = response.getWriter();
- String title = "Status of Your Order";
- String docType =
- "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
- "Transitional//EN\">\n";
- out.println(docType +
- "<HTML>\n" +
- "<HEAD><TITLE>" + title + "</TITLE></HEAD>\n" +
- "<BODY BGCOLOR=\"#FDF5E6\">\n" +
- "<H1 ALIGN=\"CENTER\">" + title + "</H1>");
- synchronized(session) {
- List itemsOrdered = cart.getItemsOrdered();
- if (itemsOrdered.size() == 0) {
- out.println("<H2><I>No items in your cart...</I></H2>");
- out.println
- ("<TABLE BORDER=1 ALIGN=\"CENTER\">\n" +
- "<TR BGCOLOR=\"#FFAD00\">\n" +
- " <TH>Item ID<TH>Description\n" +
- " <TH>Unit Cost<TH>Number<TH>Total Cost");
- out.println
- ("<TR>\n" +
- " <TR bgcolor=#339900>" +
- " <TD height=30> Shipping Information </TD></TR>" +
- " <TR><TD WIDTH=200>" +
- " <textarea name=address cols=50 rows=4></textarea></form></td>" +
- " <TD><P>"+"<LABEL>" +
- " <input type=radio name=shippingtype value=UPS Grounds>" +
- " UPS Ground </label><br>" +
- " <label>" +
- "<input type=radio name=shippingtype value=UPS 2nd Day Air>" +
- "UPS 2nd Day Air </label><br>" +
- "<label><input type=radio name=shipping values=FedEx Priority>" +
- "FedEx Priority </label><br>" +
- "<label><input type=radio name=shippingtype value=FedEx Ultra>" +
- "FedEx Ultra</label></p></form></td></tr>" +
- "<tr bgcolor=#339900>" +
- "<td height=30>Credit Card Information</td></tr>" +
- "<tr><td height=40>Card Type: </td>" +
- "<td colspan=4>" +
- "<select name=cardtype value=visa>" +
- "<option selected value=visa>Visa</option>" +
- "<option value=MasterCard>MasterCard</option>" +
- "<option value=America Express>America Express</option>" +
- "<select></form></td></tr>" +
- "<td height=30>Card Number:</td>" +
- "<td colspan=4><input type=text name=cardnum> </form></td></tr>" +
- "</form></td></tr>" +
- "<tr><t height=30>Cardholder Name:</td>" +
- "<td colspan=4><input type=text name=personname></form></td></tr><br>");
- }
- else {
- out.println ("<table border=1>" +
- "<tr bgcolor=#339900>" +
- "<th width=90>Item ID<th>Description" +
- "<th>Unit Cost <th>Number<th>Total Cost");
- ItemOrder order;
- NumberFormat formatter =
- NumberFormat.getCurrencyInstance();
- // For each entry in shopping cart, make
- // table row showing ID, description, per-item
- // cost, number ordered, and total cost.
- // Put number ordered in textfield that user
- // can change, with "Update Order" button next
- // to it, which resubmits to this same page
- // but specifying a different number of items.
- for(int i=0; i<itemsOrdered.size(); i++) {
- order = (ItemOrder)itemsOrdered.get(i);
- out.println
- ("<TR>\n" +
- " <TD>" + order.getItemID() + "\n" +
- " <TD>" + order.getShortDescription() + "\n" +
- " <TD>" +
- formatter.format(order.getUnitCost()) + "\n" +
- " <TD>" +
- "<FORM>\n" + // Submit to current URL
- "<INPUT TYPE=\"HIDDEN\" NAME=\"itemID\"\n" +
- " VALUE=\"" + order.getItemID() + "\">\n" +
- "<INPUT TYPE=\"TEXT\" NAME=\"numItems\"\n" +
- " SIZE=3 VALUE=\"" +
- order.getNumItems() + "\">\n" +
- "<SMALL>\n" +
- "<INPUT TYPE=\"SUBMIT\"\n "+
- " VALUE=\"Update Order\">\n" +
- "</SMALL>\n" +
- "</FORM>\n" +
- " <TD>" +
- formatter.format(order.getTotalCost()));
- }
- if ((straddress!=null)&&(strshippingtype!=null)
- &&(strcardtype!=null)&&(strcardnum!=null)&&(strcardname!=null))
- {
- out.println("<form action=PurchConfServletHW3 methed=Get>");
- }
- else{
- out.println("<form action=ShopCartServletHW3 method=Get>");
- out.println("Please enter your Information");
- }
- out.println(
- "</tr>"+
- "<tr bgcolor=#339900><td height=30 colspan=5>" +
- "Shipping Information</td></tr>" +
- "<tr><td with=200><textarea name=address cols=50 rows=4></textarea></td>" +
- "<td colspan=4><p>"+"<label><br />" +
- "<input type=radio name=shippingtype value=UPS Ground>" +
- "UPS Ground </label><br>" +
- "<label><input type=raio name=shippingtype value=UPS 2nd Day Air>" +
- "UPS 2nd Day Air </label>" +
- "<label><input type=radio name=shippingtype value=FedEx Priority>" +
- "FedEx Priority <label>" +
- "<label><input type=radio name=shippingtype value=FedEx Ultra>" +
- "FedEx Ultra </label></p></td></tr>" +
- "<tr bgcolor=#339900><td height=30 colspan=5>" +
- "Credit Card Information</td></tr>" +
- "<tr><td height=30>Card Type:</td>" +
- "<td colspan=4><select anme=cardtype value=visa>" +
- "option selected value=Visa>Visa</option>" +
- "option value=MasterCard>MasterCard</option>" +
- "option value=America Express>America Express</option></select></td></tr>" +
- "<tr><td height=30>Card Number:</td>" +
- "<td colspan=4><input type=text name=cardnum></td></tr></td></tr>" +
- "<tr><td height=30>Cardholder Name:</td>" +
- "<td colspan=4><input type=text name=personname></td></tr>" +
- "tr bgcolor=#339900><td height=30><input type=submit name=Sumbit4 value=Purchase></td></tr>" +
- "</form>");
- String checkoutURL =
- response.encodeURL("../Checkout.html");
- // "Proceed to Checkout" button below table
- out.println
- ("</TABLE>\n" +
- "<FORM ACTION=\"" + checkoutURL + "\">\n" +
- "<BIG><CENTER>\n" +
- "<INPUT TYPE=\"SUBMIT\"\n" +
- " VALUE=\"Proceed to Checkout\">\n" +
- "</CENTER></BIG></FORM>");
- }
- out.println("</BODY></HTML>");
- }
- }
- }