users@jersey.java.net

Re: [Jersey] How to set own content on "no content" response

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 12 Mar 2010 16:35:48 +0100

Hi Christian,

By definition a status code of 204 means that there is no entity body
in the response that is why you cannot set your own data/content. You
need to use a status code of 200.

Paul.

On Mar 12, 2010, at 2:52 PM, Abegg, Christian wrote:

> 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
>
>
>
>
>
>
>
>
>
>