View Full Version : how to apply mathematic in a jsp page
shoa
Apr 25th, 2006, 07:01 PM
Hello
I have an object house that canbe displayed in a jsp as:
<td> ${house.rentYear} </td>
It works OK.
Now I want to display also the price per month in this jsp (for viewing only). So I need to get the value of rentYear/12.
Could you please tell me how to do that
Many thanks
SHoa
ojs
Apr 26th, 2006, 04:14 AM
Now I want to display also the price per month in this jsp (for viewing only). So I need to get the value of rentYear/12.
Doesn't ${house.rentYear / 12} work?
shoa
Apr 26th, 2006, 05:00 AM
ooohhhhhh!
shoa
Apr 26th, 2006, 05:35 PM
Hello
Now I have need to format this value to 2 digit numbers. I tried in jsp page
<%
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMinimumFractionDigits(2);
%>
<%=numberFormat.format(${hour.rentYear/12}) %>
But it doesnot work.
Need help please
jonmor
Apr 27th, 2006, 05:19 AM
Hello
Now I have need to format this value to 2 digit numbers. I tried in jsp page
Use the fmt tag library from JSTL. E.g.:
<fmt:formatNumber pattern="###,##0.00" value="${hour.rentYear/12}"/>
You can specify minimum and maximum number of digits, along with various other things. You'll need to have the following at the top of your JSP, just as with the core (c:) library):
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
Colin Yates
Apr 27th, 2006, 05:42 AM
Hello
Now I have need to format this value to 2 digit numbers. I tried in jsp page
<%
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMinimumFractionDigits(2);
%>
<%=numberFormat.format(${hour.rentYear/12}) %>
But it doesnot work.
Need help please
Check out the format tag (part of sun's core tags): http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/overview-summary.html
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.