April 25, 2007, 5:17 p.m.
posted by reo
The Example ServletsThis chapter uses the Duke's Bookstore application to illustrate the tasks involved in programming servlets. Figure lists the servlets that handle each bookstore function. Each programming task is illustrated by one or more servlets. For example, BookDetailsServlet illustrates how to handle HTTP GET requests, BookDetailsServlet and CatalogServlet show how to construct responses, and CatalogServlet shows you how to track session information.
The data for the bookstore application is maintained in a database and accessed through the helper class database.BookDB. The database package also contains the class BookDetails that represents a book. The shopping cart and shopping cart items are represented by the classes cart.ShoppingCart and cart.ShoppingCartItem. The source for the bookstore application is located in the docs/tutorial/examples/web/bookstore1 directory created when you unzip the tutorial bundle (see Running the Examples (page xx)). To build, deploy, and run the example:
1 TroubleshootingCommon Problems and Their Solutions (page 65) lists some reasons why a Web client can fail. In addition, Duke's Bookstore returns the following exceptions:
Since we have specified an error page, you will see the message: The application is unavailable. Please try later. If you don't specify an error page, the Web container generates a default page containing the message A Servlet Exception Has Occurredand a stack trace that can help diagnose the cause of the exception. If you use the errorpage.html, you will have to look in the Web container's log to determine the cause of the exception. Web log files reside in the directory <JWSDP_HOME> /logsand are named jwsdp_log.<date> .txt. |
- Comment