Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing value of <c:set jstl tag

Tags:

java

jsp

jstl

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.

like image 645
john Avatar asked Dec 01 '22 22:12

john


2 Answers

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>
like image 80
Ramesh PVK Avatar answered Dec 15 '22 09:12

Ramesh PVK


why dont you just reuse the same code within your loop

<c:set var="flag" value="true" />
like image 42
storm_buster Avatar answered Dec 15 '22 09:12

storm_buster