The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search

Trail: Servlets
Lesson: Overview of Servlets

The Example Servlets

The remaining lessons in this trail show you how to write HTTP servlets. Some knowledge of the HTTP protocol is assumed; to learn more about the HTTP protocol, you could look at the RFC for HTTP/1.1.

The lessons use an example called Duke's Bookstore, a simple on-line bookstore that allows a customer to perform various functions. Each function is provided by a servlet:
 
FunctionJSDK2.0 Servlet JSDK2.1 Servlet
Browse the books offered for sale CatalogServlet CatalogServlet
Buy a book by placing it in a "shopping cart" CatalogServlet CatalogServlet
Get more information on a specific book BookDetailServlet BookDetailServlet
Manage the Bookstore Database BookDBServlet  
See the books that have been selected for purchase ShowCartServlet ShowCartServlet
Remove one or more books from the shopping cart ShowCartServlet ShowCartServlet
Buy the books in the shopping cart CashierServlet CashierServlet
Receive a Thank-You for the purchase ReceiptServlet ReceiptServlet

The lessons use the servlets to illustrate various tasks. For example, the BookDetailServlet is used to show you how to handle HTTP GET requests and the CatalogServlet is used to show you session tracking.

Several source files comprise the Duke's Bookstore example. For your convenience, we include two downloadable zip archives: one contains all of the source files necessary to build and run the example using the Java Servlet Development Kit (JSDK) version 2.0, the other contains all of the source file necessary to build and run the example using JSDK2.1.

Download the zip archive for JSDK2.0

Download the zip archive for JSDK2.1

To run the example, first start a process that runs servlets, such as servletrunner from the JSDK 2.0 or the server from the JSDK 2.1. Once the process is running, call the servlet from a browser.


Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search