The following snippet works fine in Tomcat 6,
<c:set var="abc" value="$12,345" />
<c:choose>
<c:when test="${abc ne 0}">
<c:out value="PASS"></c:out>
</c:when>
<c:otherwise>
<c:out value="FAIL"></c:out>
</c:otherwise>
</c:choose>
but throws exception in Tomcat 7.
javax.el.ELException: Cannot convert $1,2345 of type class java.lang.String to class java.lang.Long
at org.apache.el.lang.ELSupport.coerceToNumber(ELSupport.java:304)
at org.apache.el.lang.ELSupport.coerceToNumber(ELSupport.java:283)
at org.apache.el.lang.ELSupport.equals(ELSupport.java:143)
at org.apache.el.parser.AstNotEqual.getValue(AstNotEqual.java:40)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:1026)
at org.apache.jsp.WEB_002dINF.jsp.web.statussummary.status_005fsummary_jsp._jspx_meth_c_005fwhen_005f0(status_005fsummary_jsp.java:290)
Looks like there is a difference in the way the expression ${abc ne 0}
is evaulted in Tomcat 7. In Tomcat 6 both ${abc}
and ${0}
are compared as Strings but in Tomcat 7 I get this exception. I do not know why this should happen and which class file of which API is responsible for this.
How is this caused and how can I solve it?