I'm using the sql tag to pull some numbers out of the database, and our db driver is returning BigDecimal objects. I then try to use EL to do arithmetic operations on these BigDecimal objects, but it rounds everything. I dug into Coercion and PrimitiveObject, and if the Number isn't one of a standard couple, it casts it to an Integer (and thus loses my rounding). Here's a sample JSP to see the behavior: <%@ page import="java.math.*" %> <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> <% pageContext.setAttribute("a", new BigDecimal(1.5)); pageContext.setAttribute("b", new BigDecimal(2.25)); %> a + b = <c:out value="${a + b}" /> <br /> a - b = <c:out value="${a - b}" />
The JSTL 1.0 EL will be deprecated by the JSP 2.0 EL (JSR 152). This bug should be addressed by the JSR 152 expert group. I'm forwarding to the JSR 152 EG.