Bullet Points
The <jsp:useBean> standard action defines a variable that holds a reference to either an existing bean attribute or, if the bean doesn’t already exist, a new bean.
The <jsp:useBean> MUST have an “id” attribute which declares the variable name that’ll be used in this JSP to refer to the bean.
If you don’t include a “scope” attribute with <jsp:useBean>, the scope defaults to page scope.
The “class” attribute is optional, and it declares the class type that will be used if a new bean is created. The type must be public, non-abstract, and have a public no-arg constructor.
If you put a “type” attribute in <jsp:useBean>, it must be a type to which the bean can be cast.
If you have a “type” attribute but do NOT have a “class” attribute, the bean must already exist, since you haven’t specified the class type that should be instantiated for the new bean.
The <jsp:useBean> tag can have a body, and anything in the body runs ONLY if a new bean is created as a result of <jsp:useBean> (which means that no bean with that “id” was found in the specified (or default) scope).
The main purpose of the body of <jsp:useBean> is to set the new bean’s properties, using <jsp:setProperty>.
<jsp:setProperty> must have a name attribute (which will match the “id” from <jsp:useBean>), and a “property” attribute. The “property” attribute must be either an actual property name or the wildcard “*”.
If you don’t include a “value” attribute, the Container will set the property value only if there’s a request parameter with a name that matches the property name. If you use the wildcard (*) for the “property” attribute, the Container will set the value of all properties that have a matching request parameter name. (Other properties won’t be affected.)
If the request parameter name is different from the property name but you want to set the value of the property equal to the request parameter value, you can use the “param” attribute in the <jsp:setProperty> tag.
The <jsp:setProperty> action uses introspect to match the ‘property’ to a JavaBean setter method. If the property is “*”, then the JSP will iterate over all request parameters to set the JavaBean properties.
Property values can be Strings or primitives, and the <jsp:setProperty> standard action will do the conversions automatically.