users@jersey.java.net

[Jersey] Setting ETag after MessageBodyWriter has serialized entity

From: <nathan.schile_at_gmail.com>
Date: Thu, 9 Feb 2012 18:50:47 +0000 (GMT)

I would like to set the "ETag" header on the response based on a hash
of the serialized entity. After created the hash I would also like to
check if it matches the "If-None-Match" request header, and if it
matches return a status of 304 with a empty entity.

I got it so I can create the hash and set the "ETag" header in the
MessageBodyWriter, but I am unable to change the response status within
the MessageBodyWriter if the "ETag" matches the request header
"If-None-Match". Does anyone know how to accomplish this.

I also tried using a ContainerResponseFilter, but that did not work
because it is called before the entity is serialized. Thanks!

Nathan