Java Reference
In-Depth Information
T ABLE 19.1
The type of content that is in the body of the tag: JSP , empty ,or
optional tag-specific information
Names an attribute or attributes to be passed to the tag handler
Each of the subelements mentioned in Table 19.1 will be further defined as we cover the actual
development of some custom tags.
Deploying the Tag Handlers to Your Web Application
The tag handlers are the actual code that is executed when a named tag is encountered in your
JSP. The tag handlers that we will define in a later section will be compiled into class files and
deployed to the Web application.
Tag handlers can be deployed in two ways. The first is just as straight class files with a tld
defining all of the tags and their handlers in the library. You would do this by moving the class
files into the Web application's class path. When deploying to Tomcat, using our djs Web
application, you would move the class files into the <SERVER_ROOT>/webapps/djs/
WEB-INF/classes directory. The tld would then need to be moved into a directory, preferably
in the Web application space that will be referenced in the web.xml .
The second way to deploy a group of tag handlers is in a jar file. When you choose this route
you need to compile your tag handlers and jar them with their tld . The tld will need to be
added to the jar file at the top level in the /META-INF directory. The tld will also need to be
stored in a file named taglib.tld . You should then move this jar file into the classpath of the
Web application; using our djs Web application, a common location would be in the
< SERVER_ROOT>/webapps/djs/WEB-INF/lib directory.
Adding a taglib Entry to Your Web Application
After you have created your tld and deployed your tag handlers, you need to deploy the
library to your Web application. If you choose to deploy your tag library as straight class files,
you will need to directly name your tld in the Web application's web.xml file. An example of
this is in the following code snippet:
<taglib-location> /WEB-INF/tlds/taglib.tld</taglib-location>
Search WWH ::

Custom Search