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

useBean. Using type without class

 
Atul Sawant
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

in HFJS

<jsp:useBean id="person" type="foo.Person" scope="page"/>

Result if the person attribute already exists in "page" scope

it works perfectly.

Result if the person attribute does not exist in "page" scope"

java.lang.INstantitionExpection: bean person.....blah blah...

I did not understand this. Can someone give an example in which an attribute can be made available (read: to make it exists) so that there is no need to define a class there?

Thanks a lot!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65338
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are coding to modern standards, your JSP will have a page controller servlet that is invoked prior to the JSP. it is within this controller that "page preparation" activity takes place, to include the placement of scoped variables.
 
Atul Sawant
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear,

If i am getting you correctly. You mean to say that the controller servlet already creates an instance of the class "foo.person" and sets it as an attribute in context level so in the jsp, we don't need to define class in useBean, it understands which class the 'type' is refering to. Will i be correct or i am going way off the track?

Thanks for your reply!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic