Java Reference
In-Depth Information
1.
It parses the JSP.
2.
When the container encounters a custom tag, it checks for a matching prefix in the
JSP's list of taglib directives.
3.
When it finds a match, it gets the defined uri .
4.
After it has a URI, it then looks in the Web application's web.xml file for a taglib entry
where the taglib-uri and the JSP's taglib uri match.
5.
When it finds the matching URI, it gets the location of the tag library descriptor, which
is then used to map the appropriate tag handlers to the encountered tags.
Developing Custom JSP Tags Handlers
Now that we have finally gotten through the unpleasantness of deployment, let's actually
develop something that you can deploy. JSP custom tag handlers have a very simple hierarchy.
They all implement the Tag interface, either directly or through inheritance. The way they do
this depends on their type. You can develop two types of custom tags, tag with bodies and tags
without. This determines the implementation of tag handlers. Figure 19.1 shows the different
classes and their hierarchy.
<<Interface>>
Ta g
<<Interface>>
BodyTag
TagSupport
BodyTagSupport
F IGURE 19.1
The Custom Tag Class Hierarchy.
Tags Without Bodies
The first type of tag that we will discuss is a tag without a body. A tag with no body indicates
that the text between the beginning and ending custom tag elements will not be evaluated by
the associated tag handler.
As we stated in the previous section, all tags handlers must implement the Tag interface, but
there are helper classes for each type of tag. These helpers implement all of the Tag interface
Search WWH ::




Custom Search