title: Send error message as JSON object
body: <p>I have two servlet: first servlet is similar to a client and creates an <code>HttpURLConnection</code> to call the second servlet.</p>
  
  <p>I would like send a special error, formatted like a JSON object, so I call sendError method in this way: </p>
  
  <pre><code>response.sendError(code, "{json-object}")
  </code></pre>
  
  <p>But in the first servlet when I read error with <code>getResponseMessage</code> method I just get standard HTTP message and not my json object as a string.</p>
  
  <p>How I can get my json string?</p>