Reputation: 963
I am trying to achieve the below but not sure if its possible and what should the syntax be ?
<c:if condition is true>
<c:set cookie using JSTL>
</c:if>
I am thinking ,since cookie is only set on client side and JSTL is used for doing things on server side, it cannot be done.
Upvotes: 4
Views: 4435
Reputation: 1108577
You can't set a cookie using JSTL. JSTL doesn't have any tags for this functionality. JSTL runs during generating the HTTP response, while a cookie needs to be set in the HTTP response header long before generating the HTTP response. There's otherwise means of an illegal state.
Use a preprocessing servlet or filter instead wherein you can just call response.addCookie()
Upvotes: 7