• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need Help - jsp:useBean

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic