Excuse my confusion but,  HttpServletResponse does not contain the methods
setBufferSize() or flushBuffer().  Did you leave these out of your example?

Also, If you set a buffer size to 0 would there be anything there to flush?

Regards,
Craig

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Sunday, January 21, 2001 9:41 AM
To: [EMAIL PROTECTED]
Subject: Buffering of servlet responses


Hi,

Apologies if this has been asked before but the search on the mailing list
archive directs to port 9999 at the moment which I cannot access from behind
my firewall.

I'm trying to get the small servlet 'push' example below working but tomcat
appears to ignore the requests to flush it's buffers.

The content does not leave the server until the page is finished.

I'm guessing that people must be already doing this sort of thing, so what
have
I missed?

Tomcat: 3.2.1
JDK: 1.2.2
OS: Linux 2.2.18

thanks,

- Dale

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class TestPushServlet extends HttpServlet {
    public void doGet(HttpServletRequest req, HttpServletResponse resp) {
        try {
            resp.setBufferSize(0);
            resp.setContentType("text/html");

            PrintWriter out = resp.getWriter();


out.println("<html><head><title>TestPushServlet</title></head><body>");

            for (int i = 0; i < 10; i++) {
                Thread.sleep(2000);
                out.println(i + "<br>");
                out.flush();
                resp.flushBuffer();
            }
            out.println("</body></html>");
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to