Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with type attribute of jspUseBean

 
amar nath jha
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I know type attribute of useBean is used to in case when we need two objects having same name ,in the same scope in jsp.

But how to use it ???

can you post some links or small example of jsp:useBean with using type attribute.I am not getting it.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
same name ,in the same scope in jsp.

There will never be two attributes with the same name in the same scope.
 
amar nath jha
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then what exactly is the use of type in useBean action
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
using the type attribute, contrary to the class attribute, will not create a new bean if does not exist. Sorry, I can't find a proper tutorial
 
ShivKumar Rajawat
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
suppose the bean we were trying to find is not abilable or it was not set in any scope. in that case container creates a new instance of bean and sets it into the appropriate scope.

the statement that is used (after translation of JSP to servlet) to create an instance will be like
A identifier = new B()

here A is the class/interface which you defined under "type" attribute . B is the class which you defined under "class" attribute . if you do not define a type attribute , class attribute will be used for type also.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic