Reputation: 47
Iam getting the status message from the action class.Based on the status message iam displaying the two different images.
If the Status message is "Acces denied" then it show one image in the JSP page. Else we want to show an different Image.
Upvotes: 0
Views: 18725
Reputation: 1304
there is no conditions like if else in jstl instead of that jstl provides following
<c:choose>
<c:when test="${condition1}">
...
</c:when>
<c:when test="${condition2}">
...
</c:when>
<c:otherwise>
...
</c:otherwise>
</c:choose>
for more details refer this link
Upvotes: 5
Reputation: 51711
JSTL comes with <c:choose>
, <c:when>
and <c:otherwise>
tags to implement if-then-else
type logic within JSPs. Check out JSTL Core Choose Tag for a basic example.
<c:choose>
<c:when test="${a boolean expr}">
<!-- // do something -->
</c:when>
<c:when test="${another boolean expr}">
<!-- // do something else -->
</c:when>
<c:otherwise>
<!-- // do this when nothing else is true -->
</c:otherwise>
</c:choose>
Upvotes: 0
Reputation: 691645
The JSTL, surprisingly, is documented, and has an official tutorial. Google is your best friend.
You're looking for c:choose, c:when and c:otherwise:
<c:choose>
<c:when test="${status.message == 'Access Denied'}">
...
</c:when>
<c:otherwise>
...
</c:otherwise>
</c:choose>
Upvotes: 6