JSTL c:if test string not null gotcha 

Joined:
04/09/2007
Posts:
753

March 14, 2012 14:23:14    Last update: March 14, 2012 14:23:14
If forgotPasswordForm.error is a String and not null, you cannot test the error condition with:
<!-- This does not work! -->
<c:if test="${forgotPasswordForm.error}">
    <p class="error">${forgotPasswordForm.error}</p>
</c:if>


You have to use "not empty":
<c:if test="${not empty forgotPasswordForm.error}">
    <p class="error">${forgotPasswordForm.error}</p>
</c:if>
Share |
| Comment  | Tags