Skip to content
Advertisement

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.

Advertisement

Answer

Here is the sample 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>
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement