title: Set Response media type as either xml or json
body: <p>This is the code I am working with (someone else's project):</p>
  
  <pre><code>public class MyResponse
  
  public static Response success(String content) {
          MyResponse aRsponse = response(content);
          return Response.status(Status.OK).entity(aRsponse.getContent()).build();
      }
  
  public static MyResponse response(final String content) {
          return MyResponse.builder().content(content).build();
      }
  </code></pre>
  
  <p>The GET/POSTs that call the success method have <code>@Produces(MediaType.TEXT_XML)</code>preceding them. </p>
  
  <p>I have implemented some logic to determine if <code>content</code> is an XML or JSON and was thinking I'd pass that in as a param to success. So something like:</p>
  
  <p><code>public static Response success(String content, boolean isJson)</code></p>
  
  <p>Now I need to set the media type of the Response (with an if/else). I know I need something along the lines of <code>.type(MediaType.TEXT_XML);</code> but I can't seem to figure this out given the code that I have to work with and given the various examples and documentation I have found.</p>
  
  <p>Any help or steering in the right direction would be appreciated. Thanks! </p>