title: How to deal with accept-parameters when developing a jax-rs application
body: <p>In order to deal with different versions of a content-type i am trying to use the accept-parameters of the &quot;Accept*&quot; headers (<a href="https://www.rfc-editor.org/rfc/rfc2616#section-14.1" rel="nofollow noreferrer">RFC 2616</a>).</p>
  <pre><code>Accept: application/vnd.mycompany.mytype;version=2 , application/vnd.mycompany.mytype;version=1;q=0.1
  </code></pre>
  <p>The problem is that Jax-RS annotations do not support Accept-parameters...</p>
  <pre class="lang-java prettyprint-override"><code>@GET
  @Produces(&quot;application/vnd.test;version=1&quot;)
  public Response test1() {
      return Response.ok(&quot;Version 1&quot;, &quot;application/vnd.test&quot;).build();
  }
  
  @GET
  @Produces(&quot;application/vnd.test;version=2&quot;)
  public Response test2() {
      return Response.ok(&quot;Version 2&quot;, &quot;application/vnd.test&quot;).build();
  }
  </code></pre>
  <p>Results in a media type conflict exception:</p>
  <pre><code>Producing media type conflict. The resource methods public javax.ws.rs.core.Response test.resources.TestResource.test2() and public javax.ws.rs.core.Response test.resources.TestResource.test1() can produce the same media type
  </code></pre>
  <p>Maybe, this exception only related to my JAX-RS framework (Jersey), but i'm afraid this is due to the <a href="http://jsr311.java.net/nonav/releases/1.1/spec/spec.html" rel="nofollow noreferrer">JSR311</a> which is not explicit about accept-parameters.</p>
  <p>By now, i'm using content-types which holds the version within their names, but i found this solution pretty uggly.</p>
  <pre><code>@GET
  @Produces(&quot;application/vnd.test-v1&quot;)
  public Response test() {
      return Response.ok(&quot;Version 1&quot;, &quot;application/vnd.test-v1&quot;).build();
  }
  </code></pre>
  <p>Do you have any ideas about how to deal with accept-parameters ?</p>
  <p><strong>EDIT</strong></p>
  <p>I think i wasn't clear enough.
  I want to automatically route the request to specific methods.
  These methods are versioned and correspond to a specific version of the returned content-type.
  JAX-RS current implementation prevents me to use accept-parameters to route the request (to the corresponding method).</p>
  <p>greenkode suggest that i manage the <code>version</code> accept-parameter within a dispatching method (using <code>@HeaderParam(&quot;Accept&quot;)</code>).
  This solution would end-up in re-writing the content negociation logic which is embeded in the framework (and described in JSR 311).</p>
  <p>What can i do to use both accept-parameter and content-negociation logic from JAX-RS ?</p>
  <p>Maybe a solution is to use another framework (I only worked with Jersey by Now). But i don't know which one.</p>