users@jersey.java.net

Re: [Jersey] Content-Disposition

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 21 Aug 2009 10:03:20 +0200

On Aug 20, 2009, at 10:21 PM, Craig McClanahan wrote:

> dloy wrote:
>> I need to set the name of a file returned over http as a stream in
>> Jersey. Does Jersey have a mechanism for setting the Content-
>> Disposition header on a response (at this point I am not using
>> multi-part).

See also:

   https://jersey.dev.java.net/nonav/apidocs/1.1.1-ea/jersey/com/sun/jersey/core/header/ContentDisposition.html

that you can use as the value of the header.

   ContentDisposition cd =
ContentDisposition.type("file").fileName("foo").build();
   Response.ok(entity).header("Content-Disposition", cd).build();

Paul.

>> Thanks
>> David
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
> If your resource method returns a javax.ws.rs.core.Response instead
> of an entity object directly, you can use the response builder APIs
> to add whatever headers you would like (or set a response status of
> other than 200). For example:
>
> @GET
> @Path("...")
> @Produces("...")
> public Response report() {
> MyEntity entity = ...; // The data object to be written out,
> could be String or whatever
> return Response.ok(entity).header("Content-Disposition",
> "...").build();
> }
>
> Craig
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>