Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
310
Chapter 14 Creating Custom JSP Tag Libraries
behavior of the two versions. However, Tomcat 3.1 uses a slightly different
directory structure, as summarized Table 14.1. 
Table 14.1  Standard Tomcat Directories
Tomcat 3.0
Tomcat 3.1
Location of startup 
install_dir
install_dir/bin
and shutdown Scripts
Standard Top Level 
install_dir/webpages/ 
install_dir/webapps/ 
Directory for Servlets 
WEB INF/classes
ROOT/WEB INF/classes
and Supporting Classes
Standard Top Level 
install_dir/webpages
install_dir/webapps/ 
Directory for HTML 
ROOT
and JSP Files
14.1 The Components That Make 
Up a Tag Library
In order to use custom JSP tags, you need to define three separate compo 
nents: the tag handler class that defines the tag's behavior, the tag library
descriptor file that maps the XML element names to the tag implementa 
tions, and the JSP file that uses the tag library. The rest of this section gives
an overview of each of these components and the following sections give
details on how to build these components for various different styles of tags.
The Tag Handler Class
When defining a new tag, your first task is to define a Java class that tells the
system what to do when it sees the tag. This class must implement the
javax.servlet.jsp.tagext.Tag
 interface. This is usually accomplished by
extending the 
TagSupport
 or 
BodyTagSupport
 class. Listing 14.1 is an
example of a simple tag that just inserts  
Custom tag example (coreserv 
lets.tags.ExampleTag)
  into the JSP page wherever the corresponding
tag is used. Don't worry about understanding the exact behavior of this class;
that will be made clear in the next section. For now, just note that it is in the
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved