Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiple <c:when> inside <c:choose>

Tags:

java

jsp

jstl

I am just wondering whether the below code is valid?

<c:choose>
    <c:when test="${empty example1}">
    </c:when>
    <c:when test="${empty example2}">
    </c:when>
    <c:otherwise>
    </c:otherwise>              
</c:choose>
like image 726
Jay Avatar asked Sep 23 '11 20:09

Jay


1 Answers

In a c:choose, the first when for which the test is true is the winner. In the c:choose below, if "first test" and "second test" are both true, then the "Kpow" h2 will be added to the html page and the "Blammy" will not.

<c:choose>
  <c:when test="first test">
    <h2>Kpow</h2>
  </c:when>
  <c:when test="second test">
    <h2>Blammy</h2>
  </c:when>
</c:choose>
like image 74
DwB Avatar answered Nov 15 '22 20:11

DwB