I have a ContainerResponseFilter
and I tried to set a cookie in it as follows:
@Override
public void filter(ContainerRequestContext containerReq
Yeah seems a bit odd that this is not allowed. Not sure why this is not allowed. I've tested both with Jersey and Resteasy. With Resteasy, all that happens is that the cookie is not set (no Exception). I'm thinking some operation sets the cookies as headers, and by the time the filter is reached, no further operation is done with the cookies.
The only work around I can think of is to simply set the header yourself
responseContext.getHeaders().add("Set-Cookie", new NewCookie("Hello", "World"));
The toString()
of NewCookie
will return how it should look in the header
Set-Cookie: Hello=World;Version=1