• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

useBean. Using type without class

 
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!
 
Marshal
Posts: 67478
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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!
 
You save more money with a clothesline than dozens of light bulb purchases. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic