Reputation: 526
I have Jstl coding in JSP Page as
<td style="${r.p46_readback-row.p46_readback eq 0 ? 'background-color: lime':'background-color: pink'}">
<fmt:formatNumber value="${(r.p46_readback-row.p46_readback)}" maxFractionDigits="2" minIntegerDigits="2" pattern="##.## (" var="nn"></fmt:formatNumber>
<c:out value="${nn}"></c:out>
<c:choose>
<c:when test="${r.p46_readback-row.p46_readback ne 0}">
<fmt:formatNumber value="${(r.p46_readback-row.p46_readback)/r.p46_readback}" maxFractionDigits="2" minIntegerDigits="2" type="percent" var="mm"></fmt:formatNumber>
<c:out value="${mm}" ></c:out><c:out value=")"></c:out></c:when>
<c:otherwise>
<c:out value="00%)"></c:out>
</c:otherwise></c:choose></td>
Now I need to pass variable nn into java bean as a argument to a method.How to do that. Is it possible to pass variables set in tag into bean class??
Upvotes: 0
Views: 755
Reputation: 4358
There's a solution to help you archive this. Let me start from line 3 of your code:
<c:out value="${nn}"></c:out>
<%
Number number = (Number) pageContext.getAttribute("nn");
// create your java bean here and set the number variable to the bean
// after that you can do whatever you want with your bean
%>
Upvotes: 1