This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
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 Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Jsp:useBean Problem" Watch "Jsp:useBean Problem" New topic

Jsp:useBean Problem

Geeta Gune

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??
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

Joined: Jan 10, 2002
Posts: 63548

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.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Jsp:useBean Problem
It's not a secret anymore!