This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

useBean. Using type without class  RSS feed

 
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
Posts: 66188
151
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
Boost this thread!