title: REST. Jersey. How to programmatically choose what type to return: JSON or XML?
body: <p>I have 2 questions: </p>
  
  <p><strong>1.</strong> Can I create <strong>one</strong> class, annotate it with JAXB annotations(for XML support) and declare in <code>web.xml</code> </p>
  
  <pre><code>&lt;init-param&gt;
      &lt;param-name&gt;com.sun.jersey.api.json.POJOMappingFeature&lt;/param-name&gt;
      &lt;param-value&gt;true&lt;/param-value&gt;
  &lt;/init-param&gt;
  </code></pre>
  
  <p>for JSON (Jackson library) support? Or I need to create separately two classes for JSON and XML? </p>
  
  <p>Or may be exist some more elegant way to cause REST service to return both JSON and XML?</p>
  
  <p><strong>2.</strong> How I can programmatically choose what type to return (JSON or XML)?  </p>
  
  <p>Thanks.</p>