• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jsp:useBean Problem

 
Geeta Gune
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to instantiate the class using jsp:usebean when the class contains a constructor with arguments and does not contain a no-args constructor?? is it possible??
thanx
Geeta
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't believe it is possible because the javabean specification states that javabeans must have a no-arg constructor.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64830
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is not possible. If you look at any Java class generated from a JSP that uses the <jsp:useBean> tag, you will see that an instance of the bean is automatically created using the no-args contructor if no bean of that name already exists in the scope specified by the tag.
So if the "bean" class does not have a no-args contructor, the JSP class will not compile.
hth,
bear
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic