Search code examples
jspcookiesjstlel

How to show hide a div based on the existence of cookie


I want to show a div if only a cookie exists. And this is how I code it inside JSP file.

<c:if test="${ ! empty cookie['test_cookie']}">
     //some div goes here
   </c:if>

but it always shows the div. What am I doing wrong here?


Solution

  • Check not empty on cookie value: cookie.test_cookie.value:

    <c:if test="${not empty cookie.test_cookie.value}">