tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Bergsten <>
Subject Re: Problem with jsp:setProperty and blank strings
Date Tue, 18 Jul 2000 23:25:26 GMT
David Haraburda wrote:
> Hello,
>         I am having problems using the jsp:setProperty tag when I want to set a
> parameter to a blank string.  It doesn't work.  I have traced this back
> to org.apache.jasper.runtime.JspRuntimeLibrary.  For example, if I have
> the following line of JSP:
> <jsp:setProperty name="myBean" property="myProp" value=""/>
> where myBean is a bean that I have instantiated with jsp:useBean, and
> myProp is a String on myBean, with the appropriate getter and setter
> methods.  I am collecting the values from a form, so I have also tested:
> <jsp:setProperty name="myBean" property="*"/>
> and
> <jsp:setProperty name="myBean" property="myProp"/>
> I don't know if this is a bug or a feature, but in
>, on line 152 in the introspect method you check
> to see if the value is null OR an empty string.  If it is, you skip
> calling introspecthelper which would call the appropriate setter
> method.  Additionally, in introspecthelper, on line 200 of the same file
> there is the same check.  Changing these to check only for null seems to
> fix the problem.
> Is this a bug?  If it is, I would be more than happy to submit a patch
> (although the changes are trivial).  If not, why is setup to behave like
> this, and what can I do to get the behavior I want?

This is in fact how it should work according to the spec, at least for
the property and param attributes:

    The name of the Bean property whose value you want to set.
    If you set propertyName to * then the tag will iterate over the
    current ServletRequest parameters, matching parameter names
    and value type(s) to property names and setter method type(s), 
    setting each matched property to the value of the matching parameter. 
    If a parameter has a value of "", the corresponding property is not

    The name of the request parameter whose value you want to give to a
    Bean property. The name of the request parameter usually comes from a
    Web form. If you omit param, the request parameter name is assumed to 
    be the same as the Bean property name.
    If the param is not set in the Request object, or if it has the value 
    of "", the jsp:setProperty element has no effect (a noop).

There's no specified behavior for a value attribute of "" though, so I
would consider it a bug if that doesn't cause the property setter method
to be called.

Hans Bergsten
Gefion Software

View raw message