Kevin Burton wrote:

> Why can't a developer provide a constructor with a parameter list?
>
> <jsp:useBean id="test" scope="session" class="com.myCompany.test" />
>
> Is is it just me or does this seem like a major pain.  If I want to use
> a constructor with parameters I would have to write an initialize()
> method and call it via:
>

This is based on the JavaBeans requirement that the class must provide a
no-arguments constructor.  See the java.beans.Beans.instantiate() method in
the API docs -- this is the call used by a JSP to actually create the instance
if it is not there already.


>
> <%
> test.initialize("var1", "var2");
> %>
>
> IMO this just leads to bad code.  I am writing a bean that accesses an
> Oracle database.  I would like to provde a database URL, logon and
> password as part of the constructor.
>

The "politically correct" way to do this in a JSP environment is to use
<jsp:setProperty> tags inside your <jsp:useBean> tag.

>
> Any ideas?  Is this slated to become a feature down the road?
>

I would not count on this until the JavaBeans spec provides a way to
dynamically invoke an arbitrary constructor method with an
on-the-fly-constructed argument list.

>
> Kevin
>

Craig McClanahan

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to