Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can somebody explain to me the beanName attribute?

 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I found a question related to <jsp:useBean> attributes and one of the attributes was beanName. I looked at the specs and I found the following:


The name of a bean, as expected by the instantiate method
of the java.beans.Beans class.
This attribute can accept a request-time attribute expression
as a value.



Does anyone know what does this mean?
 
Colin Fletcher
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From The Java Boutique :


The beanName attribute of the <jsp:useBean> tag is used to instantiate serialized Beans rather than creating new instances from a class file. If the Bean doesn't exist in the scope, then the beanName attribute is passed on to java.beans.Bean.instantiate(), which will instantiate the Bean for the class loader. It first assumes that the name corresponds to a serialized Bean file (identified by the .ser extension) in which case it will bring it to life, but if it can't find or invoke the serialized Bean it will fall back to instantiating a new Bean from its class.
 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. That was very useful.
 
Colin Fletcher
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your Welcome. :-)
 
Durgaprasad Guduguntla
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Further you can use JSP Expression (<%=) for beanName attribute which is not possible with class attribute. You need to have both beanName and type attributes for jsp:useBean tag.

Thanks,

Durga
 
Durgaprasad Guduguntla
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This linkexplains further.

Thanks,

Durga
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic