title: HttpServletResponse redirect with application/json as Content-Type
body: <p>I'm trying to redirect a post request to get json from another host using the following code. But when I tested out, I got the error "Unsupported Media Type" and the browser also indicated that the content type of the redirected request is "text/html". </p>
  
  <p>Does anyone have idea how to correctly set the content type of a redirected request? Thanks in advance.</p>
  
  <pre><code>@Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
      String targetUrl = "http://localhost:8080/getJson";
      resp.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);
      resp.setContentType("application/json");
      resp.setHeader("Location", targetUrl);
  }
  </code></pre>