The Java EE 5 Tutorial

Declaring Tag Handlers

When tags are implemented with tag handlers written in Java, each tag in the library must be declared in the TLD with a tag element. The tag element contains the tag name, the class of its tag handler, information on the tag’s attributes, and information on the variables created by the tag (see Tags That Define Variables).

Each attribute declaration contains an indication of whether the attribute is required, whether its value can be determined by request-time expressions, the type of the attribute, and whether the attribute is a fragment. Variable information can be given directly in the TLD or through a tag extra info class. Table 8–9 lists the subelements of the tag element.

Table 8–9 tag Subelements




(optional) A description of the tag. 


(optional) name intended to be displayed by tools. 


(optional) Icon that can be used by tools. 


The unique tag name. 


The fully qualified name of the tag handler class. 


(optional) Subclass of javax.servlet.jsp.tagext.TagExtraInfo. See Declaring Tag Variables for Tag Handlers.


The body content type. See body-content Element.


(optional) Declares an EL variable exposed by the tag to the calling page. See Declaring Tag Variables for Tag Handlers.


Declares an attribute of the custom tag. See Declaring Tag Attributes for Tag Handlers.


Whether the tag supports additional attributes with dynamic names. Defaults to false. If true, the tag handler class must implement the javax.servlet.jsp.tagext.DynamicAttributes interface.


(optional) Informal description of an example use of the tag. 


(optional) Extensions that provide extra information about the tag for tools. 

body-content Element

You specify the type of body that is valid for a tag by using the body-content element. This element is used by the web container to validate that a tag invocation has the correct body syntax and is used by page-composition tools to assist the page author in providing a valid tag body. There are three possible values: