1

I want to compress or trim my jsp code as the code is becoming very large due to large number of values .I want to trim or compress the following code in two lines only,Is there any way ?

<td style="${r.p95_vmeset-row.p95_vmeset eq 0 ? 'background-color: lime':'background-color: pink'}">
<fmt:formatNumber value="${((r.p95_vmeset-row.p95_vmeset))}" maxFractionDigits="2" minIntegerDigits="2" pattern="##.##" var="nn"></fmt:formatNumber>
<c:out value="${nn}"></c:out>
<fmt:formatNumber value="${(r.p95_vmeset-row.p95_vmeset)/r.p95_vmeset}" maxFractionDigits="2" minIntegerDigits="2"  var="mm"></fmt:formatNumber>
<c:out value="(${mm})" ></c:out></td>

Means is tehre any other way to write the above code in two lines?

tiddi rastogi
  • 526
  • 3
  • 10
  • 33

1 Answers1

0

Apart from the td tags, yes it can be done in two lines...
Simply remove the assignment to the variable and move the parenthesis to the second line.

<fmt:formatNumber value="${((r.p95_vmeset-row.p95_vmeset))}" maxFractionDigits="2" minIntegerDigits="2" pattern="##.##"></fmt:formatNumber>
(<fmt:formatNumber value="${(r.p95_vmeset-row.p95_vmeset)/r.p95_vmeset}" maxFractionDigits="2" minIntegerDigits="2"></fmt:formatNumber>)

As a side note, I'm not sure if the parentheses are needed in the value tag of this one:

<fmt:formatNumber value="${((r.p95_vmeset-row.p95_vmeset))}" maxFractionDigits="2"...
Shaggy
  • 1,444
  • 1
  • 23
  • 34
  • How i will display then, if I do not use c:out – tiddi rastogi Apr 15 '15 at 07:01
  • 1
    You don't have to use c:out to display variables. The benefit of c:out is that it automatically escapes XML tags so they aren't evaluated as actual tags. You should always use it when outputting dynamic text, like data from a user input box. However, if you have a column from the database that is stored as a double, you know there isn't going to be any xml in it. In the case above, the function formatNumber would throw an error if it received a string, so you know it doesn't contain any xml in it. – Shaggy Apr 15 '15 at 12:32
  • See [this question](http://stackoverflow.com/questions/291031/jsp-cout-tag) for an explanation of the c:out tag and check out [this site](http://beginnersbook.com/2013/11/jstl-cout-core-tag/) for more info. – Shaggy Apr 15 '15 at 12:35