• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on standard action <jsp:useBean

 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<jsp:useBean id="person" class="foo.Employee" scope="request">

For above line on page 356 in HFSJ it says " if class is used (with or without type) the class must not be abstract,and must have a public no-arg constructor."

But in java no arg constructor is already supplied by compiler....so this statement didn't make any sense...Is this statement trying to explain any other condition which I am not able to understand?

Thanks
Veena
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If any other no-args constructor is specified on a class, the compiler does not supply a default no-args constructor.
 
Amru Jahagirdar
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Veena,

Suppose for the bean class you are using, if you provide a constructor with arguments, & do not provide a public no-arg constructor
then java compiler DOES NOT provide a public no-arg constructor. Such constructor is provided by compiler ONLY IF there is not one already.
So in this case, at runtime it will throw an exception as it does not find public no-arg constructor to create a bean object.
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the statement should be
" if class is used (with or without type) the class must not be abstract,and must have a public no-arg constructor,if class has constructor with arguments."

Thank you for clearing.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic