Reputation: 9
I am using a ternary operator as part of a mathematical formula. My intention is to reduce the cost of an item by 1.5% if its condition is "poor." Below is the formula:
<c:out value="${usedEquip.cost * ( 1 - ("poor" == usedEquipItem.condition ? 0.015 : 0) ) }" />
The file is a JSP running in Tomcat. This line of code produces an error which says "equal symbol expected." I suspect that the problem is something other than a missing equal sign. Can anyone see what my problem is here? Is there a better way to do this? Thank you very much!
Upvotes: 0
Views: 150
Reputation: 2810
Replace your "poor"
with 'poor'
, or escape the character by doing \"poor\".
You already have quotation mark in your value (value=""), including another quotation mark will not work in jstl.
Also you can also replace ==
with eq
Upvotes: 1