|
FAQ
History |
|
Search
Feedback |
The Example JSP Pages
This chapter describes the tasks involved in using and defining tags. The chapter illustrates the tasks with excerpts from the JSP version of the Duke's Bookstore application discussed in The Example JSP Pages rewritten to take advantage of two tag libraries: Struts and template. The third section in the chapter, Examples, describes two tags in detail: an iterator tag and the set of tags in the template tag library.
The Struts tag library provides a framework for building internationalized Web applications that implement the Model-View-Controller design pattern. Struts includes a comprehensive set of utility custom tags for handling:
The Duke's Bookstore application uses tags from the Struts
beanandlogicsublibraries.The template tag library defines a set of tags for creating an application template. The template is a JSP page with 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 could 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 with a set of nested tags--
definition,screen, andparameter--that are used to build a table of screen definitions for Duke's Bookstore and with aninserttag to insert parameters from the table into the screen.Figure 5-1 shows the flow of a request through the following Duke's Bookstore Web components:
template.jsp, which determines the structure of each screen. It uses theinserttag to compose a screen from subcomponents.screendefinitions.jsp, which defines the subcomponents used by each screen. All screens have the same banner, but different title and body content (specified by the JSP Pages column in Table 4-1).Dispatcher, a servlet, which processes requests and forwards totemplate.jsp.
![]()
Figure 5-1 Request Flow Through Duke's Bookstore Components
The template tag library files are located in the directory
<INSTALL>/j2eetutorial/examples/web/template. The classes are packaged into a JAR and already included in theWEB-INF/libdirectory of all successive versions of the Duke's Bookstore example. To recreate thetemplatelibrary JAR:The source for the Duke's Bookstore application is located in the
<INSTALL>/j2eetutorial/examples/web/bookstore3directory.To deploy and run the example:
- In the IDE, mount the filesystem
<INSTALL>/j2eetutorial/examples/web/bookstore3.- Expand the
bookstore3node.- Right-click the
WEB-INFdirectory and choose Deploy.- Set up the PointBase database as described in Accessing Databases from Web Applications.
- Open the bookstore URL
http://localhost:80/bookstore3/enter.To review the deployment settings:
|
FAQ
History |
|
Search
Feedback |
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.