Problem streaming HTML from a servlet [jigsaw 2.1.2]

G'day.

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
http://www.javaworld.com/javaworld/jw-12-1998/jw-12-servlethtml-2.html])
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>" );

    out.close();
  }

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?

Thanks!

Regards,



 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