title: Does Jetty support HTTP Chunked Responses/Transfer-Encoding?
body: <p>I'm currently using Jetty 8 and I'd like to write several events (text) in a servlet response. For example:</p>
  
  <p>write start
  write event2
  write event3
  write complete</p>
  
  <p>All delimited by \n</p>
  
  <p>The span of this response would probably be no more than 20 seconds, but the client should receive each event (line) as it happens. I could not find any documentation on this but I wanted to check with the community.</p>
  
  <p>If Jetty doesn't this, are there any other servlet engines that do and can also be embedded?</p>
  
  <p>BTW, I tried the following but no data is received until the servlet returns and then it's received all at once.</p>
  
  <pre><code>  resp.setContentType("text/html");
      resp.setHeader("Transfer-Encoding", "chunked");
      resp.getWriter().write("closing");
      resp.getWriter().flush();
  
      try {
          Thread.sleep(5000);
      } catch (InterruptedException e) {
          e.printStackTrace();
      }
  
      resp.getWriter().write("closed");
      resp.getWriter().flush();
  </code></pre>
  
  <p><strong>Edit: must use \r\n for line terminator</strong></p>