title: How to read in a Java client a response from servlet?
body: <p>I have a Java application :</p>
  
  <p>-this application send a String :</p>
  
  <pre><code>HttpClient httpClient = new DefaultHttpClient();
  
      try {
          HttpPost request = new HttpPost(url);
          StringEntity params = new StringEntity(xml);
          request.addHeader("content-type", "application/x-www-form-urlencoded");
          request.setEntity(params);
          HttpResponse response = httpClient.execute(request);
  
          // handle response here...
          String res= response.toString();
          System.out.println("RESPONSE=&gt;\n"+response); //where i read the response
      } catch (Exception ex) {
          // handle exception here
      } finally {
          httpClient.getConnectionManager().shutdown();
      }
  </code></pre>
  
  <p>I work with this String in my servlet and I just want to send a String response.</p>
  
  <pre><code>response.setContentType("text/html;charset=UTF-8");
      PrintWriter out = response.getWriter();
      out.print("TEST");
  </code></pre>
  
  <p>But when i read the response i just have my header:</p>
  
  <pre><code>RESPONSE=&gt;
  HTTP/1.1 200 OK [X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7), Server: GlassFish Server Open Source Edition 3.1.2.2, Content-Type: text/html;charset=UTF-8, Content-Length: 83, Date: Fri, 14 Dec 2012 17:17:07 GMT]
  </code></pre>
  
  <p>Someone can help me ?</p>