Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
9.4 An On Line Store Using a Shopping Cart and Session Tracking
217
Listing 9.5 OrderPage.java (continued)
          // 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.
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String title = "Status of Your Order";
    out.println(ServletUtilities.headWithTitle(title) +
                "\n" +
                "

" + title + "

");
    synchronized(session) {
      Vector itemsOrdered = cart.getItemsOrdered();
      if (itemsOrdered.size() == 0) {
        out.println("

No items in your cart...

");
      } else {
        // If there is at least one item in cart, show table
        // of items ordered.
        out.println
          ("\n" +
           "
\n" +
           "  
Item IDDescription\n" +
           "  
Unit CostNumberTotal Cost");
        ItemOrder order;
        
        // Rounds to two decimal places, inserts dollar
        // sign (or other currency symbol), etc., as
        // appropriate in current Locale.
        NumberFormat formatter =
          NumberFormat.getCurrencyInstance();
        String formURL =
          "/servlet/coreservlets.OrderPage";
        // Pass URLs that reference own site through encodeURL.
        formURL = response.encodeURL(formURL);
        // For each entry in shopping cart, make
        // table row showing ID, description, per item
        // cost, number ordered, and total cost.
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved