Professional Java Server Programming J2EE Edition
Chapter 12
-
Bodycontent is an optional attribute specifying the type of body content the tag should have.
Three values are legal: tagdependent, JSP, and empty. The default (and most useful) is
JSP, which means that the tag's body content will be evaluated at run time like any other JSP
content. tagdependent signifies that the JSP engine should not attempt to evaluate the
content, but accept that while it may not understand it, it means something to the tag handler,
and should therefore be passed unchanged. empty is useful when a tag should not have any
body content. If this value is used, and the tag is not empty, JSP translation will fail.
<attribute> sub-elements describe each attribute accepted (or required) by the tag. The DTD definition is:
<!ELEMENT attribute
(name, required?, rtexprvalue?) >
-
name is the name of this attribute, as it will appear in JSPs using the tag.
-
required specifies whether or not this attribute is mandatory. The valid values are true (the
attribute is required), and false (the default, signifying an optional attribute). The attribute
may have a default value.
-
rtexprvalue specifies whether the attribute value can be the result of a JSP expression, or
whether it has a fixed value at translation time when the tag is used in a JSP. Valid values are
true and false. Again, the default is false, meaning that expressions are forbidden. If
rtexprvalue is true, the following will be legal:
<examples:mytag attrib="<%=myObject.getValue()%>">
Allowing attributes to take expression values can be very useful. Setting attributes by the use of
expressions allows their behavior to be determined at runtime. For example, very often tag attributes
will be set to the value of properties of JSP beans. This relies on the use of a JSP expression.
The simple example's TLD was very straightforward. As this tag takes no attributes and has no associated
TagExtraInfo class, only the bare minimum of elements is required:
<?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-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>examples</shortname>
<info>Simple example library.</info>
<tag>
<name>hello</name>
<tagclass>tagext.HelloTag</tagclass>
<bodycontent>JSP</bodycontent>
<info>Simple example</info>
</tag>
</taglib>
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.