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