table of contents

Source Code Archive

Core Servlets and JavaServer Pages

Second Edition

Volume 1: Core Technologies

Chapter 9: Session Tracking

Complete source code for every example from this chapter, available free for unrestricted use. Live links to all URLs cited in the chapter. More information. To view source code for other chapters in this book, mouse over the table of contents bar on the left.

Source Code from Chapter

Note: right-click or shift-click on the links to download the associated file.

  • Servlet that uses session tracking to keep per-client access counts. Also shows other info about the session.
  • Servlet that displays a list of items being ordered. Accumulates them in an ArrayList with no attempt at detecting repeated items. Uses OrderForm.html to collect data.
  • OrderForm.html. Front end to the ShowItems servlet.
  • 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.
  • A specialization of the CatalogPage servlet that displays a page selling three famous kids-book series. Orders are sent to the OrderPage servlet.
  • A specialization of the CatalogPage servlet that displays a page selling two famous computer books. Orders are sent to the OrderPage servlet.
  • Servlet that records new item orders (if any) and then displays all items in the shopping cart.
  • Checkout.html. Page that handles the final checkout. We recommend you edit this before using it.
  • A shopping cart data structure used to track orders. The OrderPage servlet associates one of these carts with each user session.
  • Describes a catalog item for an online store. Elements of this class are indirectly stored in the ShoppingCart (after they are embedded within an ItemOrder).
  • Class that associates a catalog Iitem with a specific order by keeping track of the number ordered and the total price. Elements of this class are directly stored in the ShoppingCart (after each is populated with a CatalogItem).
  • A catalog that lists the items available in inventory.

More Information


JSF (JavaServer Faces)

Servlets & JSP
Ajax, GWT, & JavaScript

Spring, Hibernate, & JPA