<jsp:useBean>
The <jsp:useBean>
action associates a Java
bean with a name in one of the JSP scopes and makes it available as a
scripting variable. An attempt is first made to find a bean with the
specified name in the specified scope. If it’s not found, a new
instance of the specified class is created.
The <jsp:useBean>
action supports the
attributes described in Table 1-11.
Name |
Java type |
Request-time value accepted |
Description |
|
|
yes |
Optional. The name of the bean, as expected by the
|
|
|
no |
Optional. The fully qualified class name for the bean. |
|
|
no |
Mandatory. The name to assign to the bean in the specified scope and the name of the scripting variable. |
|
|
no |
Optional. The scope for the bean: one of |
|
|
no |
Optional. The fully qualified type name for the bean (i.e., a superclass or an interface implemented by the bean’s class). |
Of the optional attributes, at least one of class
or type
must be specified. If both are specified,
class
must be assignable to
type
. The beanName
attribute
must be combined with the type
attribute and is
not valid with the class
attribute.
The action is processed in these steps:
Attempt to locate an object based on the
id
andscope
attribute values.Define a scripting language variable with the ...
Get JavaServer Pages Pocket Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.