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

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(outside of the tutorial).

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:
 
FunctionTomcat Servlet JSDK2.1 Servlet
Browse the books offered for sale CatalogServlet(in a .java source file) CatalogServlet(in a .java source file)
Buy a book by placing it in a "shopping cart" CatalogServlet(in a .java source file) CatalogServlet(in a .java source file)
Get more information on a specific book BookDetailServlet(in a .java source file) BookDetailServlet(in a .java source file)
See the books that have been selected for purchase ShowCartServlet(in a .java source file) ShowCartServlet(in a .java source file)
Remove one or more books from the shopping cart ShowCartServlet(in a .java source file) ShowCartServlet(in a .java source file)
Buy the books in the shopping cart CashierServlet(in a .java source file) CashierServlet(in a .java source file)
Receive a Thank-You for the purchase ReceiptServlet(in a .java source file) ReceiptServlet(in a .java source file)

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 Tomcat, the other contains all of the source file necessary to build and run the example using JSDK2.1.

Download the zip archive for Tomcat

Download the zip archive for JSDK2.1

To run the example, first start a process that runs servlets, such as Tomcat or the JSDK2.1 server. 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
Feedback Form

Copyright 1995-2002 Sun Microsystems, Inc. All rights reserved.