I am trying to check if a cookie exists on a JSP page using the Expression Language.
I have a cookie called persist
which is set to either empty string or "checked".
If would like to check if the persist
cookie exists.
I have tried the following:
<c:if test="${cookie.persist == null}">
<c:if test="${empty cookie.persist}">
Both of the above statements are true
when the value of the persist
cookie is the empty string and false when the value of the cookie is checked
.
How do I distinguish between a cookie with the empty string as its value, and a cookie that does not exist.
(Note: I can easily work around this problem by assigning a non empty value to the cookie instead of the empty string.)
<c:if test="${empty cookie.persist}">
– Cimabue