tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <knst.koli...@gmail.com>
Subject Re: Tomcat 7.0.26 Expression Language Issue when Comparing Character Objects
Date Wed, 07 Mar 2012 20:06:55 GMT
2012/3/7 Christopher Schultz <chris@christopherschultz.net>:
>
> I think that's the deal: Tomcat takes the character from your object's
> property and decides that everything should be coerced to Long, then
> tries to coerce your String literal to a Long, which obviously does
> not work (there appear to be no rules for coercing String to Number
> unless the target type is BigDecimal. It seems ambiguous to me since
> there is no "otherwise" in section 1.18.3 when String is being coerced
> to something other than BigDecimal.

The "If N is BigInteger then:" line below it is misaligned.

After the BigInteger cases there is
"If N.valueOf(A) throws an exception, then error."

So Long.valueOf(A).

>
>> It seems a little crazy to have to workaround this issue. I
>> shouldn't have to change my code. This greatly increases the amount
>> of code changes and testing we have to do in order to move
>> applications from Tomcat 6 to 7. If this is a bug in Tomcat 7.0.26
>> (x64) then we may hold off on the upgrade. However, if it is not a
>> bug, then please explain to me why my original code no longer works
>> and the best practices for implementation.

A bug in implementation of ELSupport.equals(A,B),
https://issues.apache.org/bugzilla/show_bug.cgi?id=52666

Fixed in 7.0.26 and also in 6.0 with
http://svn.apache.org/viewvc?view=revision&revision=1245686

Before this change Strings were compared before numbers, contrary to the spec.

So you cannot stay on 6.0 without fixing your code.

>> I have identified 2 workarounds for this issue:
>> (1) Since it is a character, I can use the EL Function "contains" for
>> the comparison
>> <c:if test="${fn:contains(program.is_general_public_yn, 'N')}">
>>  <div class="sub_question">Please explain:</div><br />
>>  <c:out value="${program.general_public_explain}" />
>>  <br /><br />
>> </c:if>

fn:contains, fn:startsWith are good.

It is possible to force conversion of first operand to String and then
apply '==', e.g. ${fn:trim(program.is_general_public_yn) eq 'N'}, but
that will require more operations that just calling the above
functions.


Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message