I am dealing with problem in JSP. Basically, I want to take float number such as 0.4311223 and turn it to 4 here is how I do it:
<c:set var="age" value="${(0.4311223 * 10)}" />
<fmt:formatNumber var="ageRatio"
type="number"
value="${age}"
maxFractionDigits="0"/>
Age ratio: ${ageRatio}<br />
It prints empty string, when I print ${age} it prints correct value of 4.311223.
Did you include the taglib?
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
Please try to add the minFractionDigits
attribute. I think you can remove the type
attribute too.
<fmt:formatNumber value="${age}" minFractionDigits="0" maxFractionDigits="0"/>