This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Darcy DeClute's Scrum Master Certification Guide: The Definitive Resource for Passing the CSM and PSM Exams and have Darcy DeClute on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

JSTL number formatting

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
td><c:out value="${varApm_qpay.METRICS_IN_SLA}"/></td>
<td><c:out value="${varApm_qpay.METRICS_OUT_OF_SLA}" /></td>
<td><c:out 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 c:out
A code snippet would be highly helpful
Thanks in advance
 
Sheriff
Posts: 67735
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't need to use it with <c:out> unless you need HTML-encoding.
 
Aman Singh
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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="<c:out value='${urlVariable}' />.jsp"> <c:out
value="${varApm_qpay.APPLICATION}" /> </a></td>


<td><c:out value="${varApm_qpay.METRICS_IN_SLA}" /></td>
<td><c:out value="${varApm_qpay.METRICS_OUT_OF_SLA}" /></td>
<td><c:out value="${varApm_qpay.TOTAL_METRICS}" /></td>
<td><c:out 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
Sheriff
Posts: 67735
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 .
 
I was born with webbed fish toes. This tiny ad is my only friend:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic