InfoCenter Home >
4: Developing applications >
4.2: Building Web applications >
4.2.2: Developing JSP files >
4.2.2.3: Overview of JSP file content >
4.2.2.3.5: JSP syntax: useBean tag >
4.2.2.3.5.1a: JSP .91 syntax: <BEAN> tag syntax

4.2.2.3.5.1a: JSP .91 syntax: <BEAN> tag syntax

<bean name="bean_name" varname="local_bean_name"
type ="class_or_interface_name" introspect="yes|no"
beanName="ser_filename" create="yes|no"
scope="request|session|userprofile" >
</bean>

where the attributes are:

  • name

    The name used to look up the bean in the appropriate scope (specified by the scope attribute). For example, this might be the session key value with which the bean is stored. The value is case-sensitive.

  • varname

    The name used elsewhere within the JSP file to refer to the bean. This attribute is optional. The default value is the value of the name attribute. The value is case-sensitive.

  • type

    The name of the bean class file. This name is used to declare the bean instance in the code. The default value is the type Object. The value is case-sensitive.

  • introspect

    When the value is yes, the JSP processor examines all request properties and calls the set property methods (passed in the BeanInfo) that match the request properties. The default value of this attribute is yes.

  • beanName

    The name of the bean class file, the bean package name, or the serialized file (.ser file) that contains the bean. (This name is given to the bean instantiator.) This attribute is used only when the bean is not present in the specified scope and the create attribute is set to yes. The value is case-sensitive.

    The path of the file must be specified in the Web application classpath.

  • create

    When the value is yes, the JSP processor creates an instance of the bean if the processor does not find the bean within the specified scope. The default value is yes.

  • scope

    The lifetime of the bean. This attribute is optional and the default value is request. The valid values are:

    • request - The bean is added to the request object by a servlet that invokes the JSP file using the APIs described in JSP API. If the bean is not part of the request context, the bean is created and stored in the request context unless the create attribute is set to no.
    • session - If the bean is present in the current session, the bean is reused. If the bean is not present, it is created and stored as part of the session if the create attribute is set to yes.
    • userprofile - This attribute value is an IBM extension to JSP 0.91 and causes the user profile to be retrieved from the servlet request object, cast to the specified type, and introspected. If a type is not specified, the default type is
      com.ibm.websphere.UserProfile
      . The create attribute is ignored.

Go to previous article: JSP syntax: <useBean> tag syntax Go to next article: JSP syntax: Accessing bean properties

 

 
Go to previous article: JSP syntax: <useBean> tag syntax Go to next article: JSP syntax: Accessing bean properties