Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between class and beanName attributes of jsp:useBean

Tags:

jsp

What is the difference between class attribute and beanName attribute of jsp:useBean tag.

like image 756
Raj Avatar asked Dec 16 '22 05:12

Raj


1 Answers

Just read the <jsp:useBean> documentation (page 35). Here's an extract of relevance:

  • class="package.class" type="package.class"

    Instantiates a bean from the class named in class and assigns the bean the data type you specify in type. The value of type can be the same as class, a superclass of class, or an interface implemented by class.

    The class you specify in class must not be abstract and must have a public, no-argument constructor. The package and class names you use with both class and type are case sensitive.

  • beanName="{package.class | <%= expression %>}" type="package.class"

    Instantiates a bean from a class, a serialized template, or an expression that evaluates to a class or serialized template. When you use beanName, the bean is instantiated by the java.beans.Beans.instantiate method. The Beans.instantiate method checks whether the package and class you specify represents a class or a serialized template. If they represent a serialized template, Beans.instantiate reads the serialized form (which has a name like package.class.ser) using a class loader.

    The value of type can be the same as beanName, a superclass of beanName, or an interface implemented by beanName. The package and class names you use with both beanName and type are case sensitive.

like image 129
BalusC Avatar answered Jun 02 '23 14:06

BalusC