12.6. Evaluating Items Conditionally

JSTL provides two main tags for performing conditional evaluation: if and choose. The if tag evaluates its body only when a specified test condition is true. There is no “else” condition—the content is either included or omitted with no alternative content. The following list summarizes the use of if; the following subsections give details and examples.

  • The if tag in the jr library. Use a JSP expression for the test attribute; if the result is true or Boolean.TRUE, the contents of the tag are evaluated. For example:

    <jr:if test="<% expression %>"> 
      HTML or JSP content. 
    </jr:if> 
  • The if tag in the jx library. Use the same basic syntax as with the jr library, but specify the test by accessing an existing attribute ...

Get More Servlets and JavaServer Pages™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.