10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

To learn how to configure the example, refer to the deployment descriptor (the web.xml file),<br />

which includes the following configurations:<br />

■ A display-name element that specifies the name that tools use to identify the application.<br />

■ A welcome-file-list element that sets a particular page to be a welcome file.<br />

Tag File Location<br />

Tag files can be placed in one of two locations: in the /WEB-INF/tags/ directory or subdirectory<br />

of a web application or in a JAR file (see “Packaged Tag Files” on page 248) in the<br />

/WEB-INF/lib/ directory of a web application. Packaged tag files require a tag library descriptor<br />

(see “Tag Library Descriptors” on page 245), an XML document that contains information<br />

about a library as a whole and about each tag contained in the library. Tag files that appear in<br />

any other location are not considered tag extensions and are ignored by the web container.<br />

Tag File Directives<br />

Directives are used to control aspects of tag file translation to a tag handler, and to specify<br />

aspects of the tag, attributes of the tag, and variables exposed by the tag. Table 8–1 lists the<br />

directives that you can use in tag files.<br />

TABLE 8–1 Tag File Directives<br />

Directive Description<br />

Encapsulating Reusable Content UsingTag Files<br />

taglib Identical to taglib directive (see “Declaring Tag Libraries” on page 171) for JSP pages.<br />

include Identical to include directive (see “Reusing Content in JSP Pages” on page 173) for JSP pages.<br />

Note that if the included file contains syntax unsuitable for tag files, a translation error will<br />

occur.<br />

tag Similar to the page directive in a JSP page, but applies to tag files instead of JSP pages. As with<br />

the page directive, a translation unit can contain more than one instance of the tag directive. All<br />

the attributes apply to the complete translation unit. However, there can be only one occurrence<br />

of any attribute or value defined by this directive in a given translation unit. With the exception<br />

of the import attribute, multiple attribute or value (re)definitions result in a translation error.<br />

Also used for declaring custom tag properties such as display name. See “Declaring Tags” on<br />

page 234.<br />

attribute Declares an attribute of the custom tag defined in the tag file. See “Declaring Tag Attributes in<br />

Tag Files” on page 235.<br />

variable Declares an EL variable exposed by the tag to the calling page. See “Declaring Tag Variables in<br />

Tag Files” on page 236.<br />

Chapter 8 • CustomTags in JSP Pages 233

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!