Paul,
Thanks for the suggestions. I tried them but the GET request didn't find
the resource.
I extended the ResourceConfig class and added the .json to the end of the
GET request.
when I execute GET /chartsvcs/topspamsenderchart the request succeeds but
when I do the below it fails to find it.
executed GET /chartsvcs/topspamsenderchart.json
@Path("/chartsvcs")
public class TopSpamSenderWSImpl extends ResourceConfig {
{
@GET
@Path("/topspamsenderchart")
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response getTopSpamSenderChartTest1() throws Exception{
Object o = call something to populate object...
return Response.ok(o).type("application/json").build();
}
}
Samuel Le Berrigaud-3 wrote:
>
> 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
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
>
--
View this message in context: http://n2.nabble.com/Setting-Request-Content-Type-Dynamically-tp4172634p4177691.html
Sent from the Jersey mailing list archive at Nabble.com.