If the
jsp:useBean
element had a non empty body it is ignored. This completes the
processing of this
useBean
action.
4. If the object is not found in the specified scope and neither class nor beanName are given,
a
java.lang.InstantiationException
shall occur. This completes the
processing of this
useBean
action.
5. If the object is not found in the specified scope; and the
class
specified names a non
abstract class that defines a public no args constructor, then that class is instantiated, and
the new object reference is associated the with the scripting variable and with the
specified name in the specified scope using the appropriate scope dependent association
mechanism (see
PageContext
). After this, step 7 is performed.
If the object is not found, and the class is either abstract, an
interface
, or no public
no args constructor is defined therein, then a
java.lang.InstantiationException
shall occur. This completes the processing
of this
useBean
action.
6. If the object is not found in the specified scope; and
beanName
is given, then the method
instantiate() of
java.beans.Beans
will be invoked with the ClassLoader of the
Servlet object and the beanName as arguments. If the method succeeds, the new object
reference is associated the with the scripting variable and with the specified name in the
specified scope using the appropriate scope dependent association mechanism (see
PageContext
). After this, step 7 is performed.
7. If the
jsp:useBean
element has a non empty body, the body is processed. The variable
is initialized and available within the scope of the body. The text of the body is treated as
elsewhere; if there is template text it will be passed through to the out stream; scriptlets
and action tags will be evaluated.
A common use of a non empty body is to complete initializing the created instance; in
that case the body will likely contain
jsp:setProperty
actions and scriptlets. This
completes the processing of this
useBean
action.
Examples
In the following example, a Bean with name connection of type
com.myco.myapp.Connection
is available after this element; either because it was
already created or because it is newly created.
In this next example, the
timeout
property is set to 33 if the Bean was instantiated.
Chapter 2
Standard Syntax and Semantics
62
JSP Web Hosting JavaServer Pages Specifications JSP Hosting
|
|
|
|
TotalRoute.net Business web hosting division of Vision Web Hosting Inc. All rights reserved. |