users@jersey.java.net

[Jersey] dinamyc content type

From: Jose Antonio Illescas Del Olmo <jantonio.illescas_at_rbcdexia-is.es>
Date: Thu, 11 Aug 2011 16:04:08 +0200

How to set content type dinamically?

    @GET
    @Produces({"application/xml","text/html","text/plain"})
    public Response get(...) {
        Response.ok(something).type(?).build();
    }

Any solution without split method and use @Produces with single type? =>
It's ugly...

    @GET
    @Produces("application/xml")
    public Response getXML(...) {
        Response.ok(something).type("application/xml").build();
    }

    @GET
    @Produces("text/html")
    public Response getHTML() {
        Response.ok(something).type("text/html").build();
    }

    @GET
    @Produces("text/plain")
    public Response getTEXT() {
        Response.ok(something).type("text/plain").build();
    }

Can get the "default" contentType selected by Jersey on my method?

     Please note that Jersey (and any JAX-RS implementation) calculates
the content type to invoke the method with valid media type...