Java Reference
In-Depth Information
N
OTE
This text will not define every attribute associated with the tag library descriptor. This
would be beyond the scope of this topic. To find more information on tlds you can
look at the JSP specification.
The following code snippet contains a simple
tld
with one tag defined named
hello
:
<?xml version=”1.0” encoding=”ISO-8859-1” ?>
<!DOCTYPE taglib
PUBLIC “-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN”
“http://java.sun.com/j2ee/dtds/web-jsptaglib_1_1.dtd”>
<!-- a tab library descriptor -->
<taglib>
<tlibversion>RC1</tlibversion>
<jspversion>1.1</jspversion>
<info>DJS Tag Library</info>
<tag>
<name>hello</name>
<tagclass>com.djs.HelloTag</tagclass>
<bodycontent>empty</bodycontent>
</tag>
</taglib>
The
tld
breaks down into three main sections. The first is the document description section.
This section contains the
xml version
and the Document Type Definition (DTD) that defines
the document type of the tld. It will most often not change.
19
The second section, a child of the
taglib
entry, describes the tag library. The attributes defined
in this section are optional. Some of the entries in this part of the document define the version
of the tag library, define JSP version used by the tag library, and describe general information
about the tag library.
The last section is the most important. It is the
tag
section, also a child of the
taglib
entry.
This section describes each defined tag and the handlers that are associated with it. Table 19.1
defines the subelements available for the
tag
entry.
T
ABLE
19.1
Subelements Associated with the
tag
Entry
Subelement
Definition
The unique name of the tag
name
The tag handler class
tagclass
The
optional
class used to describe extra information about a tag
teiclass