Search code examples
jstl

JSTL Illegal text inside "c:choose" tag: "<!-- ..."


<c:choose>
    <c:when test="${somecondition}">
      ...
    </c:when>
    <!-- if not somecondition do otherwise -->
    <c:otherwise>
      ...
    </c:otherwise>
</c:choose>

The above code will throw a jspError, "JSTL Illegal text inside "c:choose" tag: "


Solution

  • <c:choose>
        <c:when test="${somecondition}">
          ...
        </c:when>
        <%-- if not somecondition do otherwise --%>
        <c:otherwise>
          ...
        </c:otherwise>
    </c:choose>
    

    You can't use < !-- --> comments. Thought I would share since I didn't see this on stackoverflow and ran into it today.

    http://youtrack.jetbrains.com/issue/IDEA-44363