FAQ
History
Previous Home Next Search
Feedback
Divider

The Example JSP Pages

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

  • The Struts logic tags were replaced with JSTL core tags.
  • The scriptlets accessing a message store were replaced with message formatting tags.
  • The JavaBeans component database helper object was replaced with direct calls to the database via the JSTL SQL tags. For most applications, it is better to encapsulate calls to a database in a bean. JSTL includes SQL tags for situations where a new application is being prototyped and the overhead of creating a bean may not be warranted.

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

To deploy and run the example:

  1. In the IDE, mount the filesystem
    <INSTALL>/j2eetutorial/examples/web/bookstore4.
  2. Expand the bookstore4 node.
  3. Right-click the WEB-INF directory and choose Deploy.
  4. Set up the PointBase database as described in Accessing Databases from Web Applications.
  5. Open the bookstore URL http://localhost:80/bookstore4/enter.

To review the deployment settings:

  1. Expand the WEB-INF node.
  2. Select the web.xml file.
  3. Select the Deployment property sheet.
  4. Browse the JSTL basename context parameter.
    1. Click the Context Parameters property and open the property editor.
    2. Notice that javax.servlet.jsp.jstl.fmt.localizationContext is set to messages.BookstoreMessages.
  5. Browse the servlet definition and servlet mappings.
    1. Click the Servlets property and open the property editor.
    2. Notice that the Dispatcher servlet is implemented by the Dispatcher class and that the URLs /enter /catalog, /bookdetails, /showcart, /cashier, and /receipt are mapped to the Dispatcher servlet.
  6. Browse the tag libraries mapping.
    1. Click the Tag Libraries property and open the property editor.
    2. Notice that the relative URI /template is mapped to /WEB-INF/lib/template.jar.
  7. Browse the resource references.
    1. Select the Resources Property sheet.
    2. Click the Resource References property and open the property editor.
    3. Note the resource reference named jdbc/BookDB.
Divider
FAQ
History
Previous Home Next Search
Feedback
Divider

All of the material in The J2EE Tutorial for the Sun ONE Platform is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.

AltStyle によって変換されたページ (->オリジナル) /