You might want to use the javax.ws.rs.core.Response class,
@GET
@Path("/topspamsenderchart")
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response getTest()
{
Response.ok(something.fetch).type(calculateContentType()).build();
}
HTH,
SaM
On Wed, Dec 16, 2009 at 9:34 AM, cgswtsu78 <cgray_at_proofpoint.com> wrote:
>
> Hello,
>
> Does anyone know how I can use a querystring parameter to set the content
> type of the request.
>
> For example if I have a resource method that accepts both XML and JSON, how
> can I let the consumer (via a url GET request) decide what content type they
> want to be returned? Is there an annotation I can use in order to map a
> querystring request parameter to dynamically set the requests content type?
>
>
> @GET
> @Path("/topspamsenderchart")
> @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
> public Object getTest()
> {
>
> Object o = something.fetch;
>
> return o;
> }
> --
> View this message in context: http://n2.nabble.com/Setting-Request-Content-Type-Dynamically-tp4172634p4172634.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>