title: Can Jersey convert a GET returned POJO to XML or JSON depending on the request's Accept header?
body: <p>This question is for Jersey 2.x.</p>
  
  <p>Let's say I have a GET method. The client request contains an Accept header for either XML or JSON.  Is it possible for the method to return a POJO in the representation the client requested?</p>
  
  <p>Currently, my GET method returns JSON using Jackson.  But I don't know how to make it return XML when the client requests it.  All the examples I see here expect the POJO to be JAXB annotated.</p>
  
  <p>The POJO being returned doesn't have JAXB annotations and I'm not allowed to add them.  But the object does fulfill the JavaBean contract, so it's a real POJO.</p>
  
  <p>Since Jackson can serialize a POJO (with no annotations) to JSON , I hope there's an existing MessageBodyWriter that does the same for XML.</p>
  
  <p>If this is possible:
  - How do I annotate the GET method?  Currently, I use the line below.  Is this enough?</p>
  
  <pre><code>@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML })
  </code></pre>
  
  <ul>
  <li>I'm configuring Jersey through web.xml and Maven.  I've got JSON serialization working, but I haven't figured out how to configure for XML output.  What config is needed to make XML work?</li>
  </ul>
  
  <p>Thanks for your help.</p>