Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
212
Chapter 9 Session Tracking
Listing 9.2 CatalogPage.java (continued)
   *  To see the HTML that results from this method, do
   *  "View Source" on KidsBooksPage or TechBooksPage, two
   *  concrete classes that extend this abstract class.
   */
  
  public void doGet(HttpServletRequest request,
                    HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html");
    if (items == null) {
      response.sendError(response.SC_NOT_FOUND,
                         "Missing Items.");
      return;
    }
    PrintWriter out = response.getWriter();
    out.println(ServletUtilities.headWithTitle(title) +
                "\n" +
                "

" + title + "

");
    Item item;
    for(int i=0; i
      out.println("
");
      item = items[i];
      // Show error message if subclass lists item ID
      // that's not in the catalog.
      if (item == null) {
        out.println("" +
                    "Unknown item ID " + itemIDs[i] +
                    "");
      } else {
        out.println();
        String formURL =
          "/servlet/coreservlets.OrderPage";
        // Pass URLs that reference own site through encodeURL.
        formURL = response.encodeURL(formURL);
        out.println
          ("
\n" +
           "
           "       VALUE=\"" + item.getItemID() + "\">\n" +
           "

" + item.getShortDescription() +

           " ($" + item.getCost() + ")\n" +
           item.getLongDescription() + "\n" +
           "

\n

\n" +
           "
           "VALUE=\"Add to Shopping Cart\">\n" +
           "\n

\n");

}
    }
    out.println("
\n");
  }
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