Hi,
i want to do arithmetic operation on jsp . I am using struts tag lib tag
following is the code :
<s:set name="value1" value ="%{0.0}" />
<s:set name="value2" value ="%{0.0}" />
<s:set name="percent" value ="%{0.0}" />
<s:iterator>
<s:set name="value1" value ="%{#value1+ someIntegerValue1}" />
<s:set name="value2" value ="%{#value2+ someIntegerValue2}" />
</s:iterator>
<s:set name="percent" value ="%{(#value1*100.0)/#value2}" />
<fmt:formatNumber type="number" maxFractionDigits="2" minFractionDigits="2" value="${percent}" />
now the last line always rounds to integer value
like if value1 = 3 , value2 = 31 . then percent should be equal to (3*100)/31 = 9.68
BUT the damn thing outputs to 9.00
<s:set name="percent" value ="%{(3*100.0)/31.0}" />
<fmt:formatNumber type="number" maxFractionDigits="2" minFractionDigits="2" value="${percent}" />
then it outputs correctly 9.68 :S
can anyone please help ?? Now when i hardcode this expression
I have been banging my head on this for a long time, googling for more than 2-3 hours didnt get me anything .