I want to do something like the following:
<c:choose>
<c:when test="${empty example1}">
</c:when>
<c:otherwise>
<c:when test="${empty example2}">
</c:when>
<c:otherwise>
</c:otherwise>
</c:otherwise>
</c:choose>
Is this even possible? I get an exception thrown when trying to run.
Thank you.
JSP lets you even define your own tags (you must write the code that actually implement the logic of those tags in Java). JSTL is just a standard tag library provided by Sun (well, now Oracle) to carry out common tasks (such as looping, formatting, etc.).
JSTL stands for JSP Standard Tag Library. JSTL is the standard tag library that provides tags to control the JSP page behavior. JSTL tags can be used for iteration and control statements, internationalization, SQL etc.
c:out escapes HTML characters so that you can avoid cross-site scripting.
The < c:if > tag is used for testing the condition and it display the body content, if the expression evaluated is true. It is a simple conditional tag which is used for evaluating the body content, if the supplied condition is true.
You need to do it more like this:
<c:choose>
<c:when test="${empty example1}">
<!-- do stuff -->
</c:when>
<c:otherwise>
<c:choose>
<c:when test="${empty example2}">
<!-- do different stuff -->
</c:when>
<c:otherwise>
<!-- do default stuff -->
</c:otherwise>
</c:choose>
</c:otherwise>
</c:choose>
The verbosity shown here is a good example of why XML is a poor language for implementing multi-level conditional statements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With