• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need Help - jsp:useBean

 
Ranjit Jana
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at jsp:useBean specification

<jsp:useBean id="beanInstanceName"
scope="page|request|session|application"
{
class="package.class" [ type="package.class" ]|
beanName="{package.class | '${' Expression '}' | <%= expression %>}" type="package.class" |
type="package.class"
}
{ /> | > other elements </jsp:useBean> }



as you can see "beanName can do everything "class" can do it even have support to EL and expression . what is the significance of class ?

Can we use both "class" and "beanName" together? the specification says its not possible.

Do write whatever you know about this two attribute even though it may not related to this question.

Regards,
Ranajit
 
srinath anand
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a little explanation from JWebPlus:


<jsp:useBean id="name" scope="page|request|session|application" typeSpec />
typeSpec ::=class="className" ||
class="className" type=="typeName" ||
type="typeName" beanName=="beanName" ||
type="typeName"
If the Bean is not already instantiated then the container looks for class or beanName attribute to instantiate an object and then if type is present, it casts the object to the type.
Normally, type is used when you want to cast the bean object to some interface or superclass. In such a case, class attribute specifies the class of the bean and type specifies the interface.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic