users@jersey.java.net

How to set own content on "no content" response

From: Abegg, Christian <cha_at_zuehlke.com>
Date: Fri, 12 Mar 2010 14:52:34 +0100

Hi

I am trying to set my own data/content to a response with http response code 204 (no content).

I tried the following:

This response object results in a HTTP response with status code 204:
return Response.status(Status.NO_CONTENT).build();
But I get the following content:
<data contentType="null" contentLength="0"><![CDATA[]]></data>

Adding an entity to the response builder, I get HTTP response with the correct data but with HTTP response code 200.
1) return Response.status(Status.NO_CONTENT).entity(new GenericResponse()).build();
2) return Response.noContent().entity(new GenericResponse()).build();

How can I influence the returned content on an response object with status code 204 ?

Regards,
Christian