• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:useBean question?

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this a valid way of declaring a jsp:useBean?

<jsp:useBean id="user" beanName="myco.User" class="myco.util.User" />

What is that beanName doing here?
 
Mirko Bonasorte
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No,
you cannot use useBean and class together.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
beanName cannot be used with class. It has to be used with type. It is used to instanciate a Bean (see the JavaBeans specification) using the instanciate method of java.beans.Beans.

Here is a little explanation : http://www.jguru.com/faq/view.jsp?EID=26545
[ July 09, 2007: Message edited by: Satou kurinosuke ]
 
Mirko Bonasorte
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah ha, Satou!

This time I was faster!
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jothi,

As per the syntax of jsp:useBean mentioned here



The beanName is used to instantiate a Bean from either a class or a serialized template, using the JavaBeans API. Though it looks similar to that of "class" attribute, it uses to instantiate a Bean from a template as well.

I remember i have read it in HFSJ that you can either use class or name attribute but no need to use them both.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good guys. Thanks for the help. I got it!
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, thats correct. Thanks Satou.

Now i remember, you CANNOT use beanName and class both in the useBean syntax.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This time I was faster!

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Satou, you rock!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic