'Changing value of <c:set jstl tag
I am using the following expression on my jsp
<c:set var="flag" value="false" />
I have a condition inside a for each loop where I might want to change this variable to true. Is there a way to do this. I've looked everywhere but unable to find a solution.
Solution 1:[1]
why dont you just reuse the same code within your loop
<c:set var="flag" value="true" />
Solution 2:[2]
You could do this as well
<c:set var="flag" value="${(yourcondition)? true : false}"/>
Solution 3:[3]
Simply,
Syntax:
<c:set var="flag" value="${(condition)}" />
Ex:
<c:set var="flag" value="${(myVariable == "stackoverflow")}" />
<c:out value="${flag}" /> // true or false
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | storm_buster |
| Solution 2 | Vijay Kalidindi |
| Solution 3 |
