Mantis - Resin
Viewing Issue Advanced Details
5590 major always 11-19-13 03:46 02-13-14 18:54
VladV  
alex  
normal  
closed 4.0.37  
fixed  
none    
none 4.0.39  
0005590: JSTL bug: empty values handled incorrectly in fmt:formatNumber tag
Empty (null) values passed to fmt:formatNumber as "value" attribute are handled incorrectly: instead of being displayed as empty values, they are displayed as values from previously evaluated fmt:formatNumber tags. Please see the example below.

If the value is passed as the tag content, not as an attribute, everything works as expected.
Code to reproduce the bug:
<%@ page pageEncoding="utf-8" trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" [^] %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" [^] %>
<html>
<head>
<title>JSP Test Page</title>
</head>
<body>
<c:set var="x" value="12.345" />
<c:set var="y" value="${null}" />
[<fmt:formatNumber maxFractionDigits="2" value="&0000036;{x}"/>]
[<fmt:formatNumber maxFractionDigits="2" value="&0000036;{y}"/>]
[<fmt:formatNumber maxFractionDigits="2">&0000036;{x}</fmt:formatNumber>]
[<fmt:formatNumber maxFractionDigits="2">&0000036;{y}</fmt:formatNumber>]

</body>
</html>

Output:
[12.34]
[12.34] <-- this should be empty
[12.34]
[]

Notes
(0006397)
alex   
02-13-14 18:51   
jsp/1dbd
(0006398)
alex   
02-13-14 18:53   
fixed in 4.0.39
(0006399)
alex   
02-13-14 18:54   
jsp/1dbd