Name
<jsp:useBean>
Synopsis
The
<jsp:useBean>
action associates a Java bean with a name in one of the JSP scopes
and also 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.
Syntax 1: Using a concrete class, no body
<jsp:useBean id="beanVariableName
" class="className
" [scope="page
|request|session|application"] />
Syntax 2: Using a concrete class, with a body
<jsp:useBean id="beanVariableName
" class="className
" [scope="page
|request|session|application"]> Evaluated if a new instance is created </jsp:useBean>
Syntax 3: Using a type and optionally a class or a serialized bean, no body
<jsp:useBean id="beanVariableName
" type="className
" [class="className
" | beanName="className
"] [scope="page
|request|session|application"] />
Syntax 4: Using a type and optionally a class or a serialized bean, with a body
<jsp:useBean id="beanVariableName
" type="className
" [class="className
" | beanName="className
"] [scope="page
|request|session|application"]> Evaluated if a new instance is created </jsp:useBean>
Attributes
Attribute name |
Java type |
Dynamic value accepted |
Description |
beanName |
String |
Yes |
The name of the bean, as expected by the |
class |
String |
No |
The fully qualified class name for the bean. |
id |
String |
No |
The name to assign to the bean in the specified scope, as well as the name ... |
Get JavaServer Pages, 3rd Edition 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.