The JavaTM Web Services Tutorial
Home
TOC
Index
PREV TOP NEXT
Divider

The Example JSP Pages

This chapter illustrates JSTL with excerpts from the JSP version of the Duke's Bookstore application discussed in Chapter 15 rewritten as follows:

The source for the Duke's Bookstore application is located in the <JWSDP_HOME>/docs/tutorial/examples/web/bookstore4 directory created when you unzip the tutorial bundle (see Running the Examples).

To build, install, and run the example:

  1. In a terminal window, go to <JWSDP_HOME>/docs/tutorial/examples/web/bookstore4.
  2. Run ant build. The build target will spawn any necessary compilations and copy files to the <JWSDP_HOME>/docs/tutorial/examples/web/bookstore4/build directory.
  3. Make sure Tomcat is started.
  4. Run ant install. The install target notifies Tomcat that the new context is available.
  5. Start the PointBase database server and populate the database if you have not done so already (see Accessing Databases from Web Applications).
  6. Open the bookstore URL http://localhost:8080/bookstore4/enter.

To deploy the application using deploytool:

  1. Make sure Tomcat is started.
  2. Start deploytool.
  3. Create a Web application called bookstore4.
    1. Select FileNew Web Application.
    2. Click Browse.
    3. In the file chooser, navigate to <JWSDP_HOME>/docs/tutorial/examples/web/bookstore4/build.
    4. In the File Name field, enter bookstore4.
    5. Click Choose Module File.
    6. In the WAR Display Name field, enter bookstore4.
    7. Click Edit to add the content files. In the Edit Contents dialog, navigate to <JWSDP_HOME>/docs/tutorial/examples/web/web/bookstore4/build. Select the JSP pages banner.jsp, bookstore.jsp, bookdetails.jsp, catalog.jsp, showcart.jsp, cashier.jsp, receipt.jsp, template.jsp, screendefinitions.jsp, and errorpage.jsp, and duke.books.gif and click Add. Navigate to WEB-INF. Add Dispatcher.class and the cart, database, messages, taglib, and util packages from classes and the JSTL TLDs and libraries from lib. Click OK.
    8. Click Next.
    9. Select the Servlet radio button.
    10. Click Next.
    11. Select Dispatcher from the Servlet class combo box.
    12. Click Finish.
  4. Add the aliases.
    1. Select Dispatcher
    2. Select the Aliases tab.
    3. Click Add and then type /enter in the Aliases field. Repeat to add the aliases /catalog, /bookdetails, /showcart, /cashier, and /receipt.
  5. Add the JSTL basename context parameter.
    1. Select the Context tab.
    2. Click Add.
    3. Enter javax.servlet.jsp.jstl.fmt.localizationContext for the Coded Parameter.
    4. Enter messages.BookstoreMessages for the Value.
  6. Add a resource reference for the database.
    1. Select the WAR.
    2. Select the Resource Refs tab.
    3. Click Add.
    4. Select javax.sql.DataSource from the Type column
    5. Enter jdbc/BookDB in the Coded Name field.
    6. Click the Import Data Sources button.
    7. Dismiss the confirmation dialog.
    8. Select pointbase from the drop down list.
  7. Add the tag library URI to location mappings (see Declaring Tag Libraries):
    1. Select the File Refs tab.
    2. Click the Add button in the JSP Tag Libraries tab.
    3. Enter the relative URI /tutorial-template in the Coded Reference field.
    4. Enter the absolute location /WEB-INF/tutorial-template.tld in the Tag Library field.
    5. Repeat for /jstl-c to /WEB-INF/c.tld, /jstl-fmt to /WEB-INF/fmt.tld, and /jstl-sql to /WEB-INF/sql.tld.
  8. Deploy the application.
    1. Select Tools->Deploy.
    2. Click OK to select the default context path /bookstore4.
    3. Click Finish.

See Common Problems and Their Solutions and Troubleshooting for help with diagnosing common problems.

Divider
Home
TOC
Index
PREV TOP NEXT
Divider

This tutorial contains information on the 1.0 version of the Java Web Services Developer Pack.

All of the material in The Java Web Services Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.