The Example JSP Pages

This chapter describes the tasks involved in defining simple tags. We illustrate the tasks using excerpts from the JSP version of the Duke's Bookstore application discussed in The Example JSP Pages (page 97), rewritten here to take advantage of several custom tags:

The tutorial-template tag library defines a set of tags for creating an application template. The template is a JSP page that has placeholders for the parts that need to change with each screen. Each of these placeholders is referred to as a parameter of the template. For example, a simple template might include a title parameter for the top of the generated screen and a body parameter to refer to a JSP page for the custom content of the screen. The template is created using a set of nested tags--definition, screen, and parameter--that are used to build a table of screen definitions for Duke's Bookstore. An insert tag to insert parameters from the table into the screen.

Figure 7-1 shows the flow of a request through the following Duke's Bookstore web components:

Request Flow Through Duke's Bookstore Components

Figure 7-1 Request Flow through Duke's Bookstore Components

The source code for the Duke's Bookstore application is located in the <INSTALL>/javaeetutorial5/examples/web/bookstore3/ directory created when you unzip the tutorial bundle (see About the Examples, page xxx). To build the example, follow these steps:

  1. In a terminal window, go to <INSTALL>/javaeetutorial5/examples/bookstore3/.
  2. Run ant. This target will spawn any necessary compilations, copy files to the <INSTALL>/javaeetutorial5/examples/web/bookstore3/build/ directory, package a WAR file, and copy it to the <INSTALL>/javaeetutorial5/examples/web/bookstore3/dist/ directory.
  3. Start the Application Server.
  4. Perform all the operations described in Accessing Databases from Web Applications (page 54).

To deploy the example, run ant deploy. Ignore the URL that the deploy target gives you. To run the application, use the URL given at the end of this section instead.

To learn how to configure the example, refer to the web.xml file, which includes the following configurations:

To run the example, open the bookstore URL http://localhost:8080/bookstore3/bookstore.

See Troubleshooting (page 60) for help with diagnosing common problems.