users@jersey.java.net

Re: [Jersey] how to set the response encoding ?

From: Felipe Gaścho <fgaucho_at_gmail.com>
Date: Sat, 29 Aug 2009 19:29:31 +0200

humm.. but I have already a response type..

my method:

        @GET
        @Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
        @Path("{offset}/{limit}/{groupId}")
        public Collection<PujUserEntity> selectAllByGroup(
                        @PathParam("offset") int offset, @PathParam("limit") int limit,
                        @PathParam("offset") String groupId) {
                return facade.readAllByGroupId(offset, limit, groupId);
        }


How to set the chraset (and other headers) of the HTTP response ?

On Sat, Aug 29, 2009 at 7:25 PM, Craig
McClanahan<Craig.McClanahan_at_sun.com> wrote:
> Felipe Gaścho wrote:
>>
>> How to set the response encoding of my Jersey resources ?
>>
>> * or other response HTTP headers ?
>>
>>
>
> Have your resource method return a "javax.ws.rs.core.Resonse" instead of an
> entity object class directly.  You can use its "builder pattern" APIs to add
> as many headers as you like:
>
>   @GET
>   public Response get(...) {
>       Object entity = ...; // The object you would normally have been
> returning
>       return Response.ok(entity).
>           header("Content-Language", "en-us").
>           build();
>   }
>
> There are also shortcut methds for many of the common HTTP headers, as well
> as a way to set status codes other than 200.
>
> Craig
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>



-- 
Looking for a client application for this service:
http://fgaucho.dyndns.org:8080/footprint-service/wadl