I have a condition inside ...">

Changing the value of <c: set jstl tag

I use the following expression on my jsp

<c:set var="flag" value="false" /> 

I have a condition inside a for each loop where I can change this variable to true. Is there any way to do this. I searched everywhere, but could not find a solution.

+4
source share
3 answers

Here is an example of the code you are looking for:

 <c:choose> <c:when test="${yourcondition}"> <c:set var="flag" value="true" /> </c:when> <c:otherwise> <c:set var="flag" value="false" /> </c:otherwise> </c:choose> 
+8
source

why don't you just use the same code in your loop

 <c:set var="flag" value="true" /> 
+6
source

You can also do it

 <c:set var="flag" value="${(yourcondition)? true : false}"/> 
+2
source

All Articles