jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sgarlata Matt" <sgarlata_m...@bah.com>
Subject EL weirdness - bug or feature?
Date Sat, 16 Aug 2003 22:34:21 GMT
I ran into some strange behavior using the eq and == operators in the 
EL.  It looks like an empty string (that is, '') is equal to 0.  Is that 
correct?  Here is the JSP I am using to test:

<c:if test="${null eq 0}">
	Null equals 0.
</c:if>
<c:if test="${'' eq 0}">
	An empty string equals 0.
</c:if>

This prints out:

An empty string equals 0.

Is this a bug or a feature?  I think it's a bug.  In the JSTL spec 
section A.3.6.2 where the eq and ne operators are defined it states, "If 
A or B is String coerce both A and B to String, compare lexically"  In 
this case I think 0 should be converted to '0' and the comparison should 
fail.  Please let me know, and if it is a bug I will enter it in BugZilla.

Thanks,

Matt


Mime
View raw message