title: Cannot Compress Java Server Response Sent To JSP
body: <p>I am having trouble in returning compressed response (GZip) from my Java Servlet, to a JSP.</p>
  
  <p>Flow :  </p>
  
  <ol>
  <li>Request comes to java servlet  </li>
  <li>Process the request, and create a JSON object, with the response  </li>
  <li>Convert the JSON object to string  </li>
  <li>Compress the response string with GZip  </li>
  <li>The compressed response string is set as attribute in the request object and control passed to JSP  </li>
  <li>In the JSP, the response string (compressed) is printed on screen  </li>
  </ol>
  
  <p>Precautions :  </p>
  
  <ol>
  <li>Request object has "Accepting-Encoding" set with "gzip"  </li>
  <li>Response header has "Content-Encoding" set to "gzip"  </li>
  <li>Response content type is set to "application/json"  </li>
  <li>Response character encoding is set to "ISO-8859-1"  </li>
  </ol>
  
  <p>Result :  </p>
  
  <ol>
  <li>Firefox shows "Content Encoding Error"  </li>
  <li>Chrome shows "Error 330 (net::ERR_CONTENT_DECODING_FAILED): Unknown error."  </li>
  </ol>
  
  <p>Can anyone help point me out, in the right direction please?</p>