• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL number formatting

 
Aman Singh
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need to use it with <cut> unless you need HTML-encoding.
 
Aman Singh
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic