aspose file tools*
The moose likes JSP and the fly likes JSTL number formatting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL number formatting" Watch "JSTL number formatting" New topic
Author

JSTL number formatting

Aman Singh
Ranch Hand

Joined: Oct 30, 2008
Posts: 57
td><cut value="${varApm_qpay.METRICS_IN_SLA}"/></td>
<td><cut value="${varApm_qpay.METRICS_OUT_OF_SLA}" /></td>
<td><cut value="${varApm_qpay.TOTAL_METRICS}" /></td>

I am using the above mentioned code to access a data and then display it on my jsp page. My problem is that I want to truncate the decimal values that are being displayed on my jsp page. for example 15.0 should be 15.

Can anyone please suggest me a way to do it in JSTL. I think fmt:formatNumber can do this, but I dont know how to use it with cut
A code snippet would be highly helpful
Thanks in advance
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

You don't need to use it with <cut> unless you need HTML-encoding.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Aman Singh
Ranch Hand

Joined: Oct 30, 2008
Posts: 57
<table border="1" cellspacing="1" bgcolor="#FFFFFF">

<thead>
<tr>
<th>Application</th>
<th>Metrics_in_sla</th>
<th>Metrics_out_of_sla</th>
<th>Total_metrics</th>
<th>Sla_compliance</th>
</tr>
</thead>
<tbody>
<c:forEach var="varApm_qpay" items="${apm_qpay}">
<tr bgcolor="E5E5E5">
<td><c:url value="${varApm_qpay.APPLICATION}" var="urlVariable"></c:url>
<a href="<cut value='${urlVariable}' />.jsp"> <cut
value="${varApm_qpay.APPLICATION}" /> </a></td>


<td><cut value="${varApm_qpay.METRICS_IN_SLA}" /></td>
<td><cut value="${varApm_qpay.METRICS_OUT_OF_SLA}" /></td>
<td><cut value="${varApm_qpay.TOTAL_METRICS}" /></td>
<td><cut value="${varApm_qpay.SLA_COMPLIANCE}%" /></td>
</tr>
</c:forEach>
</tbody>
</table>

Now the values fetched from 2nd, 3rd and 4th column are integers and I want to get rid of .0 that comes automatically. (20.0 should be 20)
Can you please suggest a way
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

Use <fmt: numberFormat>.

And, please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL number formatting