How to use if-else option in JSTL

Srinivasan picture Srinivasan · Jan 3, 2011 · Viewed 488.7k times · Source

Is there an if-else tag available in JSTL?

Answer

skaffman picture skaffman · Jan 3, 2011

Yes, but it's clunky as hell, e.g.

<c:choose>
  <c:when test="${condition1}">
    ...
  </c:when>
  <c:when test="${condition2}">
    ...
  </c:when>
  <c:otherwise>
    ...
  </c:otherwise>
</c:choose>