tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: Patch for bug report #362 (and a patch for a logging error)
Date Fri, 10 Nov 2000 22:58:31 GMT
Serge Knystautas wrote:

> Ok, I submitted the bug report this afternoon (#362) about how jasper was
> mishandling a custom tag of mine.  You can read the report if you want, but
> basically here's what happens... say your custom tag has an attribute to be
> rtexprvalue and because of the flexibility of the tag, you make the setter
> method take a java.lang.Object value.  When you then set a non-dynamic value
> in your JSP (rather than passing some object, just write attr="value"),
> jasper throws this funny message that says it "can't cast String to
> java.lang.Object."
> Not a high priority thing, but I think pretty useful (especially since I'd
> like to use these custom tags I wrote!!)  I read over the JSP spec several
> times and don't see how this would be a violation of the spec.  Included
> below is the 2 line patch.


I'm afraid that I disagree with you about whether this change would be spec
compliant or not.  The reasoning is based on an implication (not clearly
specified in JSP 1.1, but made explicit in 1.2) that the conversions performed
when setting a custom tag attribute are the same as those used by
<jsp:setProperty/>, described in Section 2.13.2 of the JSP 1.1 spec.  In

    "The only types of properties that can be assigned to from
    String constants and request parameter values are those listed
    in Table 2-4; the conversion applied is that shown in the table.
    Request-time expressions can be assigned to properties of
    any type; no automatic conversion will be performed."

Thus, you also have a workaround.  Assume you've got a custom tag "foo" that has
a property (of class java.lang.Object) named "bar".  Your patch would enable

    <mytags:foo bar="abc"/>

which the page compiler will currently complain about.  However, the following
will work just fine (assuming you've defined this attribute to accept runtime

    <mytags:foo bar='<%= "abc" %>'/>

which accomplishes the same thing.

We can ask Eduardo (the spec lead for JSP) about this next week when he returns
from vacation, but the intent is pretty clear -- doing this conversion is
explicitly illegal in JSP 1.2 -- so I'd prefer not to put this change into
Tomcat 3.2.


View raw message