The servlet below works under Linux with Sun JDK 1.2.2, tomcat 3.3 dev to
Netscape 4.7 on NT.
Different browsers handle push differently, you'll need to experiment.
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.setContentType("text/html");
PrintWriter out = resp.getWriter();
out.println("<html><body>");
for (int i = 0; i < 10; i++) {
Thread.sleep(2000);
out.println(i + "<br>");
out.flush();
}
out.println("</body></html>");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
On Mon, Jan 29, 2001 at 03:15:20PM -0800, Sean Agnew wrote:
> Thanks for the tip. I tried the 3.3 (zip file) versions w/ no luck. Do you
> think I'd be better off trying the Unix versions? Or perhaps the 4.0 beta?
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Monday, January 29, 2001 2:50 PM
> To: [EMAIL PROTECTED]
> Subject: Re: getting server push to work
>
>
> This doesn't work with tomcat 3.2 try one of the nightly 3.3 builds.
>
> thanks,
>
> - Dale
>
> On Mon, Jan 29, 2001 at 11:47:43AM -0800, Sean Agnew wrote:
> >
> > Iv'e not had any luck with server push and Tomcat. Flushing the
> PrintWriter
> > doesn't seem to be sending any data. The Browser only hangs until the
> > servlet is completely finished. How can I disable Tomcat from buffering
> > servlet output?
> >
> >
> > response.setContentType("multipart/x-mixed-replace;boundary=boundary");
> > PrintWriter out = response.getWriter();
> > String s = "Awaiting query results, please wait ...\n";
> > out.println("--boundary");
> > out.println("Content-Type: text/html\r");
> > out.println("\r");
> > out.println(s);
> > out.println("\r");
> > out.println("--boundary--");
> > out.println("\r");
> > out.flush();
> > try {
> > Thread.sleep(3000);
> > } catch (Exception e) {
> > out.println("interrupted: " + e);
> > }
> >
> > out.println("Content-Type: text/html\r");
> > out.println("\r");
> > out.println("This is the end");
> > out.println("--boundary--");
> > out.flush();
> >
> >
> >
> > __________________________________________
> > NetZero - Defenders of the Free World
> > Get your FREE Internet Access and Email at
> > http://www.netzero.net/download/index.html
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, email: [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
>
>
> __________________________________________
> NetZero - Defenders of the Free World
> Get your FREE Internet Access and Email at
> http://www.netzero.net/download/index.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]