Java Reference
In-Depth Information
The
taglib
Directive
The most recent version of the JSP specification defines a mechanism for extending the current
set of JSP tags. It does this by creating a custom set of tags called a
tag library
. That is what
the
taglib
points to. The
taglib
directive declares that the page uses custom tags, uniquely
names the tag library defining them, and associates a tag prefix that will distinguish usage of
those tags. The syntax of the
taglib
directive is as follows:
<%@ taglib uri=”
tagLibraryURI
” prefix=”
tagPrefix
” %>
The
taglib
attributes are described in Table 14.2.
T
ABLE
14.2
The Attributes for the
taglib
Directive
Attribute
Definition
This attribute references a URI that uniquely names the set of custom tags.
uri
This attribute defines the prefix string used to distinguish a custom tag
instance.
prefix
Standard Actions
JSP standard actions provide an abstraction that can be used to easily encapsulate common
tasks. They typically create or act on objects, normally JavaBeans. The JSP technology pro-
vides some standard actions. These actions are briefly defined in the following list; we'll
explore them in more detail in Chapter 16, “JSP Standard Actions”:
•
<jsp:useBean>
The
<jsp:useBean>
action associates an instance of a JavaBean
defined with a given scope and ID, using a newly declared scripting variable of the same
ID.
•
<jsp:setProperty>
The
<jsp:setProperty>
action sets the value of a bean's
property.
•
<jsp:getProperty>
The
<jsp:getProperty>
action takes the value of the referenced
bean instance's property, converts it to a
java.lang.String
, and places it into the
implicit
out
object.
•
<jsp:include>
The
<jsp:include>
action provides a mechanism for including addi-
tional static and dynamic resources in the current JSP page.
•
<jsp:forward>
The
<jsp:forward>
action enables the JSP engine to dispatch, at run-
time, the current request to a static resource, servlet, or another JSP.