Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
14.3 Assigning Attributes to Tags
321
The Tag Library Descriptor File
Tag attributes must be declared inside the
tag
element by means of an
attribute
element. The
attribute
element has three nested elements that
can appear between
and
.
1.
name
, a required element that defines the case sensitive
attribute name. In this case, I use
length
2.
required
, a required element that stipulates whether the
attribute must always be supplied (
true
) or is optional (
false
).
In this case, to indicate that
length
is optional, I use
false
If you omit the attribute, no call is made to the
setAttribute
Name
method. So, be sure to give default values to the fields that
the method sets.
3.
rtexprvalue
, an optional attribute that indicates whether the
attribute value can be a JSP expression like
<%= expression %>
(
true
) or whether it must be a fixed
string (
false
). The default value is
false
, so this element is
usually omitted except when you want to allow attributes to
have values determined at request time.
Listing 14.8 shows the complete
tag
element within the tag library
descriptor file. In addition to supplying an
attribute
element to describe
the
length
attribute, the
tag
element also contains the standard
name
(
prime
),
tagclass
(
coreservlets.tags.PrimeTag
),
info
(short descrip
tion), and
bodycontent
(
EMPTY
) elements.
Listing 14.8 csajsp taglib.tld
PUBLIC " //Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web jsptaglibrary_1_1.dtd">
"http://java.sun.com/j2ee/dtds/jsptaglibrary_1_2.dtd"
>
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved