This tag is used to create a instance of java bean first of all it tries to find out the bean if bean instance already exist assign stores a reference to it in the variable. If we specified type, gives the Bean that type.otherwise instantiates it from the class we specify, storing a reference to it in the new variable.so jsp:usebean is simple way to create a java bean.
Â Â Â
a element contains a element that sets property values in the Bean,we have element also to get the value from the bean.
Explanation of Attribute
A variable that identifies the Bean in the scope we specify. If the Bean has already been created by another element, the value of id must match the value of id used in the original element.
scope="page | request | session | application"
The scope in which the Bean exists and the variable named in id is available. The default value is page. The meanings of the different scopes are shown below:
page â€“ we can use the Bean within the JSP page with the element
request â€“ we can use the Bean from any JSP page processing the same request, until a JSP page sends a response to the client or forwards the request to another file.
session â€“ we can use the Bean from any JSP page in the same session as the JSP page that created the Bean. The Bean exists across the entire session, and any page that participates in the session can use it..
application â€“ we can use the Bean from any JSP page in the same application as the JSP page that created the Bean. The Bean exists across an entire JSP application, and any page in the application can use the Bean.
Instantiates a Bean from a class, using the new keyword and the class constructor. The class must not be abstract and must have a public, no-argument constructor.
If the Bean already exists in the scope, gives the Bean a data type other than the class from which it was instantiated. If you use type without class or beanName, no Bean is instantiated.