2.13
Standard Actions
The JSP 1.1 specification defines some standard action types that are always available,
regardless of the version of the JSP container or Web server the developer uses. The standard
action types are in addition to any custom types specific to a given JSP container
implementation.
2.13.1
A
jsp:useBean
action associates an instance of a Java programming language object
defined within a given
scope
available with a given
id
via a newly declared scripting
variable of the same
id
.
The
jsp:useBean
action is quite flexible; its exact semantics depends on the attributes
given. The basic semantic tries to find an existing object using
id
and
scope
; if it is not
found it will attempt to create the object using the other attributes. It is also possible to use
this action only to give a local name to an object define elsewhere, as in another JSP page or
in a Servlet; this can be done by using the
type
attribute and not providing neither
class
nor
beanName
attributes.
At least one of
type
and
class
must be present, and it is not valid to provide both
class
and
beanName
. If
type
and
class
are present,
class
must be assignable (in the Java
platform sense) to
type;
failure to do so is a translation time error.
The attribute
beanName
is the name of a Bean, as specified in the JavaBeans specification
for an argument to the instantiate() method in java.beans.Beans. I.e. it is of the form a.b.c ,
which may be either a class, or the name of a resource of the form a/b/c.ser that will be
resolved in the current ClassLoader. If this is not true, a request time exception, as indicated
in the semantics of instantiate() will be raised. The value of this attribute can be a request
time attribute expression.
The actions performed are:
1. Attempt to locate an object based on the attribute values (
id,
scope
). The inspection is
done appropriately synchronized per scope namespace to avoid non deterministic
behavior.
2. Define a scripting language variable with the given
id
in the current lexical scope of the
scripting language of the specified
type
(if given) or
class
(if type is not given).
3. If the object is found, the variable's value is initialized with a reference to the located
object, cast to the specified
type
. If the cast fails, a
java.lang.ClassCastException
shall occur. This completes the processing of
this
useBean
action.
61
JavaServer Pages 1.1 Specification
November 30, 1999
JSP Web Hosting JavaServer Pages Specifications JSP Hosting
|
|
|
|
TotalRoute.net Business web hosting division of Vision Web Hosting Inc. All rights reserved. |