Java Reference
In-Depth Information
What Are Standard Actions?
JSP standard actions are predefined tags that can be used to easily encapsulate common
actions. There are two types of JSP standard actions: those related to JavaBean functionality
and all other standard actions. Each group will be defined and used, where appropriate, in the
following sections.
JavaBean Standard Actions
Three standard actions are defined to help integrate JavaBeans into JSPs: <jsp:useBean> ,
<jsp:setProperty> , and <jsp:getProperty> .
The <jsp:useBean> Standard Action
The first standard action is < jsp:useBean> . It associates an instance of a JavaBean defined
with a given scope and id using a newly declared scripting variable of the same id .
The < jsp:useBean> action is very flexible. Its exact semantics depend on the values of the
given attributes. The basic action tries to find an existing object using the same id and scope .
If it does not find an existing instance, it will attempt to create the object. It is also possible to
use this action only to give a local name to an object defined elsewhere, as in another JSP page
or in a servlet. This can be done by using the type attribute, and by not providing the class or
the beanName attribute. The syntax of the < jsp:useBean> action is as follows:
<jsp:useBean id=” name
typeSpec ::=class=” className ” |
class=” className ” type=” typeName ” |
type=” typeName ” class=” className ” |
beanName=” beanName ” type=” typeName ” |
type=” typeName ” beanName=” beanName ” |
type=” typeName
Table 16.1 contains the attributes of the <jsp:useBean> action.
T ABLE 16.1
The Attributes for the <jsp:useBean> Action
This attribute represents the identity of the instance of the object in the
specified scope. The name is case sensitive and must satisfy the current
scripting language's variable naming conventions.
Search WWH ::

Custom Search