How can i check if an attribute is set (not null and not an empty string) with jstl?

Sergio del Amo picture Sergio del Amo · May 15, 2009 · Viewed 66.4k times · Source

E.g.

<c:if test="${post}">
    <h3>${post.title}</h3>  
</c:if>

Answer

krosenvold picture krosenvold · May 15, 2009

Use the empty keyword

<c:if test="${not empty post}">
   <h3>${post.title}</h3>   
</c:if>