title: Jetty servlet does not detect that client has disconnected
body: <p>This is the code of the servlet that I deployed to Jetty:</p>
  
  <pre><code>public class StreamServlet extends HttpServlet
  {
    public void doGet( HttpServletRequest request, 
      HttpServletResponse response ) throws ServletException, IOException
    {
      response.setContentType( "text/xml; charset=UTF-8" );
      response.setCharacterEncoding( "UTF-8" );
  
      InputStream is = this.getServletContext().getResourceAsStream( "A.xml" );
      BufferedReader reader = new BufferedReader( 
          new InputStreamReader( is, Charset.forName("UTF-8") ) );
  
      String line = "";
      try
      {
        while( (line = reader.readLine()) != null ) {
          getServletContext().log( line );
          writer.println( line );
          writer.flush();
          Thread.sleep( 1500 ); // for testing
        }
      }
      catch (InterruptedException e)
      {
          getServletContext().log("exception",e);
      }
    }
  }
  </code></pre>
  
  <p>I then ran on the command line</p>
  
  <pre><code>curl -i http://localhost:8080/foo/servlet
  </code></pre>
  
  <p>The file <code>A.xml</code> contains about 13,000 lines; so <strong>curl</strong> correctly displayed each line it received after 1.5 seconds. I then interrupted <strong>curl</strong>, but to my surprise the servlet continued on running; i.e in this while loop.</p>
  
  <pre><code>while( (line = reader.readLine()) != null ) {
    getServletContext().log( line );
    writer.println( line );
    writer.flush();
    Thread.sleep( 1500 ); // for testing
  }
  </code></pre>
  
  <p>Why does it exhibit this behaviour? I am not using continuations. I am running Jetty 6.1.26. What I want: the servlet thread should stop when it detects that the client has terminated the http connection. </p>