How to define empty or null. C tags from JSTL?

terry73

New member
How can I check if a String is null or empty using JSTL's c tags?

I have a variable called var1 that I can show, but I'd like to add a comparator to validate it.
Code:
<c:out value="${var1}" />

When it is null or empty, I want to validate it (my values are strings).
 

terry73

New member
Update: I've googled it to get my answer & to know more about the conditional operators in C. I've found it from Scaler and they suggested using an empty keyword in a <c:if> for this:
Code:
<c:if test="${empty var1}">
    var1 is empty or null.
</c:if>
<c:if test="${not empty var1}">
    var1 is NOT empty or null.
</c:if>
 
Last edited: