Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
210
Chapter 9 Session Tracking
page title and the identifiers of the items listed on the page. The actual page
is then built automatically by methods in the parent class, based upon item
descriptions stored in the catalog. The second subsection shows the page that
handles the orders. It uses session tracking to associate a shopping cart with
each user and permits the user to modify orders for any previously selected
item. The third subsection presents the implementation of the shopping cart,
the data structures representing individual items and orders, and the catalog.
DILBERT reprinted by permission of United Syndicate, Inc.
Building the Front End
Listing 9.2 presents an abstract base class used as a starting point for servlets
that want to display items for sale. It takes the identifiers for the items for
sale, looks them up in the catalog, and uses the descriptions and prices found
there to present an order page to the user. Listing 9.3 (with the result shown
in Figure 9 3) and Listing 9.4 (with the result shown in Figure 9 4) show
how easy it is to build actual pages with this parent class. 
Listing 9.2 CatalogPage.java 
package coreservlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
/** Base class for pages showing catalog entries.
 *  Servlets that extend this class must specify
 *  the catalog entries that they are selling and the page
 *  title before the servlet is ever accessed. This
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