W3C home > Mailing lists > Public > www-jigsaw@w3.org > November to December 2000

Problem streaming HTML from a servlet [jigsaw 2.1.2]

From: Greg Kopff <gkopff@powersource.com.au>
Date: Tue, 28 Nov 2000 16:38:59 +0000
Message-Id: <>
To: www-jigsaw@w3.org

I'm currently writing a servlet to tail a file (essentially a tail -f).
The servlet needs to read the file, flush that content to the output
stream, then wait for more data to appear in the file, read it, flush it etc.

The following sample code (not mine, but showing the same problem [from
exhibits the problem im seeing.

  public void doGet(HttpServletRequest req, HttpServletResponse res) 
         throws ServletException, IOException
    res.setContentType( "text/html" );

    PrintWriter out = res.getWriter();

    out.println( "<html><head><title>Example 5</title></head>" );
    out.println( "<body>" );
    out.println( "<h1>Countdown</h1>" );
    for ( int i = 10; i > 0; i-- ) {
        out.print( "<h1>" );
        out.print( i );
        out.println( "</h1>" );
        out.flush(); // make sure the browser see the count
        try {
            Thread.sleep( 1000 );
        catch ( InterruptedException e ) {}
    out.println( "<h1>Liftoff</h1>" );
    out.println( "</body></html>" );


I'm using Jisaw 2.1.2.  In all the browsers I can find (Win98 Netscape 6,
Win98 MS Exploder, Linux Netscape 6, Konqueror, even telnetting to port
8001) the content is not output to the client following a flush(), and only
appears after the close() call is made.

Is this a bug?  Or is the servlet output filtered by Jigsaw (and so not
flushed by the filter until the close() occurs)?  Is there a work around?



 Greg Kopff
gkopff@powersource.com.au      PowerSource Software
Technical Director    http://www.powersource.com.au
  "We mock what we don't understand."
                               - Austin Millbarge
Received on Tuesday, 28 November 2000 00:39:16 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:41:29 UTC