E.g.
<c:if test="${post}"> <h3>${post.title}</h3> </c:if>
The first way is to use the JSTL tag and empty operator to check if an ArrayList is empty and the second way is to use the JSTL function, fn: length() instead of the empty operator as shown in our example.
The Java programming language distinguishes between null and empty strings. An empty string is a string instance of zero length, whereas a null string has no value at all. An empty string is represented as "" . It is a character sequence of zero characters.
To check if a string is null or empty in Java, use the == operator.
Summarized: empty doesn't work on Set when using the ancient JSTL 1.0. You'd need to upgrade to JSTL 1.1 (which is from 2003 already).
Use the empty keyword
<c:if test="${not empty post}"> <h3>${post.title}</h3> </c:if>
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