Bug 10134 - EL coercion not handling BigDecimal properly
Summary: EL coercion not handling BigDecimal properly
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Standard Taglib (show other bugs)
Version: 1.0
Hardware: Other other
: P3 major (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2002-06-21 19:14 UTC by Serge Knystautas
Modified: 2004-11-16 19:05 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Serge Knystautas 2002-06-21 19:14:28 UTC
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}" />
Comment 1 Justyna Horwat 2002-06-27 23:44:44 UTC
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.