users@jersey.java.net

[Jersey] produce multiple resource types in a single method

From: Dário Abdulrehman <dario.rehman_at_gmail.com>
Date: Mon, 26 Oct 2009 11:16:39 +0000

Hi,

When a resource method produces several response types how do you actually
construct each response type?

For example, given:

@GET
@Produces({"application/json", "application/xml"})
public Response doGet(@QueryParam("x") String x) {

}

How do you know if you should construct a response with JSON or plain XML?
Is there any alternative to creating several doGet methods (doGetAsJSON
doGetAsXML, etc...), each with a single @Produces annotation for each return
type?

Thanks.