users@jersey.java.net

[Jersey] default media type for jersey

From: Rashid Jilani <jilani_at_lifebiosystems.com>
Date: Wed, 8 Dec 2010 11:22:53 -0600

Hi: Gurus, I would like to know what would be the default media type in
jersey if client doesn't provide one with the client call.

 

Second what is the best design pattern to return multiple data format on the
basis of the client request call.

 

E.g lets say I have to return xml, JSON, csv etc formats on the basis of the
call coming from the client like this

 

http://localhost:8084/Rootcontext/resourceName/{id.xm
<http://localhost:8084/Rootcontext/resourceName/%7bid.xm> l} //Return xml

http://localhost:8084/Rootcontext/resourceName/{id.json} //Return json

http://localhost:8084/Rootcontext/resourceName/{id.csv} //Return csv

 

I am not sure how to call different resource methods that produces different
data format

 

@Produces({MediaType.APPLICATION_JSON})

 

@Produces({MediaType.APPLICATION_XML})

 

@Produces({MediaType.TEXT_XML})

 

Any help would be really appreciated.

 

Regards,

RJ