aspose file tools*
The moose likes JSP and the fly likes Jsp:useBean Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Jsp:useBean Problem" Watch "Jsp:useBean Problem" New topic
Author

Jsp:useBean Problem

Geeta Gune
Greenhorn

Joined: Mar 19, 2002
Posts: 17
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

Joined: Mar 09, 2001
Posts: 2676
I don't believe it is possible because the javabean specification states that javabeans must have a no-arg constructor.


Matthew Phillips
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60082
    
  65

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jsp:useBean Problem
 
Similar Threads
jsp:useBean
jsp:usebean
problem with jsp:useBean tag
javaBeans without default constructor
jsp:beans - class must be instantiated - but why?