You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Jonathan Eric Miller <je...@uchicago.edu> on 2001/08/21 17:47:11 UTC
Fw: Bug in ServletResponse.flushBuffer() in Tomcat 4.0b7?
I originally posted this to the tomcat-user list, but, I received no
response. As far as I can tell, it's a bug, so, I'm now forwarding this to
the developer list in hopes that someone here might be able to confirm
whether this is a bug or not.
If you know the answer and respond, please respond to me directly or post to
the user list as I am not on this list.
Thanks a lot. I think you guys are doing a great job. It's just a few small
issues like this that I hope to resolve at this point.
Jon
----- Original Message -----
From: "Jonathan Eric Miller" <je...@uchicago.edu>
To: "Tomcat User List" <to...@jakarta.apache.org>
Sent: Thursday, August 16, 2001 2:14 PM
Subject: Bug in ServletResponse.flushBuffer() in Tomcat 4.0b7?
> I'm having problems using ServletResponse.flushBuffer() and Tomcat 4.0b7.
> The following servlet demonstrates.
>
> What I want it to do is print out the title and the "Test 1" line. Then,
> pause for 10 seconds and print out the "Test 2" line. It doesn't work the
> first time through. However, if I then hit Refresh in my browser after
going
> through it once, you can see clearly that it prints out the first line
> pauses and prints out the last line as I would expect it to. Is this a
bug?
> Can someone else reproduce this?
>
> The reason I want to get this to work is that I have a servlet where I
have
> a page with a Submit button on it, then on the next page, there is
sometimes
> a few second lag while performing an update on a directory/database. I've
> had problems in the past where users click the Submit multiple times
because
> they think it's stuck. Actually, it's not, it's just slow. So, what I want
> to do is print out at least the top part of the page so that the Submit
> button/previous page is no longer available for them to click on. If
someone
> could fix this for the final version of Tomcat 4, I would greatly
appreciate
> it. Either that or, if anyone else knows of a work around, that would be
> appreciated too.
>
> Thanks, Jon
>
> import java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> public class SimpleServlet extends HttpServlet
> {
> public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws
> IOException
> {
> try
> {
> resp.setContentType("text/html");
>
> PrintWriter pw = resp.getWriter();
>
> pw.println("<html><head><title>SimpleServlet</title></head><body>");
>
> pw.println("<p>Test 1</p>");
>
> pw.flush();
>
> resp.flushBuffer();
>
> Thread.sleep(10000);
>
> pw.println("<p>Test 2</p>");
>
> pw.println("</body></html>");
>
> pw.close();
> }
> catch(Exception e)
> {
> System.out.println(e);
> }
> }
> }
>
>
Re: Bug in ServletResponse.flushBuffer() in Tomcat 4.0b7?
Posted by "Pier P. Fumagalli" <pi...@betaversion.org>.
Jonathan Eric Miller at jemiller@uchicago.edu wrote:
> I originally posted this to the tomcat-user list, but, I received no
> response. As far as I can tell, it's a bug, so, I'm now forwarding this to
> the developer list in hopes that someone here might be able to confirm
> whether this is a bug or not.
>
> If you know the answer and respond, please respond to me directly or post to
> the user list as I am not on this list.
>
> Thanks a lot. I think you guys are doing a great job. It's just a few small
> issues like this that I hope to resolve at this point.
Verified that Tomcat is working correctly. Replied to the Users mailing list
and him.
Pier
Re: Fw: Bug in ServletResponse.flushBuffer() in Tomcat 4.0b7?
Posted by Jonathan Eric Miller <je...@uchicago.edu>.
Thanks Craig. I think one of the other developers replied to me regarding
this issue awhile back. You are correct. It does seem to be working
correctly. I found out that Internet Explorer does some buffering on the
client-side and that was what caused the problem. Someone told me that you
have to send at least 256 characters to IE before it will display. I tested
that, and that does indeed seem to be what's happening.
Thanks, Jon
----- Original Message -----
From: "Craig R. McClanahan" <cr...@apache.org>
To: "Tomcat Developer List" <to...@jakarta.apache.org>
Cc: <je...@uchicago.edu>
Sent: Monday, August 27, 2001 4:35 PM
Subject: Re: Fw: Bug in ServletResponse.flushBuffer() in Tomcat 4.0b7?
>
>
> On Tue, 21 Aug 2001, Jonathan Eric Miller wrote:
>
> > Date: Tue, 21 Aug 2001 10:47:11 -0500
> > From: Jonathan Eric Miller <je...@uchicago.edu>
> > Reply-To: tomcat-dev@jakarta.apache.org
> > To: Tomcat Developer List <to...@jakarta.apache.org>
> > Subject: Fw: Bug in ServletResponse.flushBuffer() in Tomcat 4.0b7?
> >
> > I originally posted this to the tomcat-user list, but, I received no
> > response. As far as I can tell, it's a bug, so, I'm now forwarding this
to
> > the developer list in hopes that someone here might be able to confirm
> > whether this is a bug or not.
> >
> > If you know the answer and respond, please respond to me directly or
post to
> > the user list as I am not on this list.
> >
> > Thanks a lot. I think you guys are doing a great job. It's just a few
small
> > issues like this that I hope to resolve at this point.
> >
> > Jon
> >
>
> Jon,
>
> I tried this with Tomcat 4.0 stand alone (current CVS code, Linux, JDK
> 1.3.1) and it works exactly as you expect -- you see the first part of the
> output, followed by a ten-second delay, followed by the second part. (Of
> course, I had to put the Thread.sleep() call into a try/catch block.)
>
> As you undoubtedly noticed, the HTML that you emit before the flush has to
> be completed paragraphs or other elements -- otherwise the characters will
> still get buffered inside the browser itself. One way to ensure that the
> browser is not messing you up is to do a telnet connection:
>
> telnet localhost 8080
>
> and type
>
> GET /myapp/servlet/SimpleServlet HTTP/1.0
>
> followed by a carriage return (^M) and line feed (^J).
>
> Craig
>
>
Re: Fw: Bug in ServletResponse.flushBuffer() in Tomcat 4.0b7?
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Tue, 21 Aug 2001, Jonathan Eric Miller wrote:
> Date: Tue, 21 Aug 2001 10:47:11 -0500
> From: Jonathan Eric Miller <je...@uchicago.edu>
> Reply-To: tomcat-dev@jakarta.apache.org
> To: Tomcat Developer List <to...@jakarta.apache.org>
> Subject: Fw: Bug in ServletResponse.flushBuffer() in Tomcat 4.0b7?
>
> I originally posted this to the tomcat-user list, but, I received no
> response. As far as I can tell, it's a bug, so, I'm now forwarding this to
> the developer list in hopes that someone here might be able to confirm
> whether this is a bug or not.
>
> If you know the answer and respond, please respond to me directly or post to
> the user list as I am not on this list.
>
> Thanks a lot. I think you guys are doing a great job. It's just a few small
> issues like this that I hope to resolve at this point.
>
> Jon
>
Jon,
I tried this with Tomcat 4.0 stand alone (current CVS code, Linux, JDK
1.3.1) and it works exactly as you expect -- you see the first part of the
output, followed by a ten-second delay, followed by the second part. (Of
course, I had to put the Thread.sleep() call into a try/catch block.)
As you undoubtedly noticed, the HTML that you emit before the flush has to
be completed paragraphs or other elements -- otherwise the characters will
still get buffered inside the browser itself. One way to ensure that the
browser is not messing you up is to do a telnet connection:
telnet localhost 8080
and type
GET /myapp/servlet/SimpleServlet HTTP/1.0
followed by a carriage return (^M) and line feed (^J).
Craig
Re: DTD DOCTYPE wrong in examples....?
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Tue, 21 Aug 2001, Thom Park wrote:
> Date: Tue, 21 Aug 2001 14:00:34 -0700
> From: Thom Park <tp...@borland.com>
> Reply-To: tomcat-dev@jakarta.apache.org
> To: tomcat-dev@jakarta.apache.org
> Subject: DTD DOCTYPE wrong in examples....?
>
> Hello,
>
> Sun appear to have changed the DOCTYPE for the web application in servlet
> specification 2.3.
> Actually, in the draft spec it states that the doc type is:
>
> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
> Application 2.3//EN" "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
>
> however, the actual location appears to be:
>
> http://java.sun.com/dtd/web-app_2_3.dtd
>
This is the value that will be in the final spec (because that is where
the DTD actually lives). I have just committed a fix to bring all the
webapps included with Tomcat 4 up-to-date with respect to this.
NOTE: Depending on what XML parser you use, an out-of-date value will not
matter. Tomcat registers an internal copy of the DTD with its parser, so
that as long as you get the public identifier correct, the parser will
*not* try to retrieve the DTD across the network.
>
> -Thom
>
Craig
DTD DOCTYPE wrong in examples....?
Posted by Thom Park <tp...@borland.com>.
Hello,
Sun appear to have changed the DOCTYPE for the web application in servlet
specification 2.3.
Actually, in the draft spec it states that the doc type is:
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
however, the actual location appears to be:
http://java.sun.com/dtd/web-app_2_3.dtd
Can anyone shed some light on what it should be? Practically speaking,
the only way to get this file to work (if you're using a DTD parser) is to
specify the latter URL, however the Spec still insists that the former
should be
used.
Which should it be?
-Thom
-----Original Message-----
From: Jonathan Eric Miller [mailto:jemiller@uchicago.edu]
Sent: Tuesday, August 21, 2001 8:47 AM
To: Tomcat Developer List
Subject: Fw: Bug in ServletResponse.flushBuffer() in Tomcat 4.0b7?
I originally posted this to the tomcat-user list, but, I received no
response. As far as I can tell, it's a bug, so, I'm now forwarding this to
the developer list in hopes that someone here might be able to confirm
whether this is a bug or not.
If you know the answer and respond, please respond to me directly or post to
the user list as I am not on this list.
Thanks a lot. I think you guys are doing a great job. It's just a few small
issues like this that I hope to resolve at this point.
Jon
----- Original Message -----
From: "Jonathan Eric Miller" <je...@uchicago.edu>
To: "Tomcat User List" <to...@jakarta.apache.org>
Sent: Thursday, August 16, 2001 2:14 PM
Subject: Bug in ServletResponse.flushBuffer() in Tomcat 4.0b7?
> I'm having problems using ServletResponse.flushBuffer() and Tomcat 4.0b7.
> The following servlet demonstrates.
>
> What I want it to do is print out the title and the "Test 1" line. Then,
> pause for 10 seconds and print out the "Test 2" line. It doesn't work the
> first time through. However, if I then hit Refresh in my browser after
going
> through it once, you can see clearly that it prints out the first line
> pauses and prints out the last line as I would expect it to. Is this a
bug?
> Can someone else reproduce this?
>
> The reason I want to get this to work is that I have a servlet where I
have
> a page with a Submit button on it, then on the next page, there is
sometimes
> a few second lag while performing an update on a directory/database. I've
> had problems in the past where users click the Submit multiple times
because
> they think it's stuck. Actually, it's not, it's just slow. So, what I want
> to do is print out at least the top part of the page so that the Submit
> button/previous page is no longer available for them to click on. If
someone
> could fix this for the final version of Tomcat 4, I would greatly
appreciate
> it. Either that or, if anyone else knows of a work around, that would be
> appreciated too.
>
> Thanks, Jon
>
> import java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> public class SimpleServlet extends HttpServlet
> {
> public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws
> IOException
> {
> try
> {
> resp.setContentType("text/html");
>
> PrintWriter pw = resp.getWriter();
>
> pw.println("<html><head><title>SimpleServlet</title></head><body>");
>
> pw.println("<p>Test 1</p>");
>
> pw.flush();
>
> resp.flushBuffer();
>
> Thread.sleep(10000);
>
> pw.println("<p>Test 2</p>");
>
> pw.println("</body></html>");
>
> pw.close();
> }
> catch(Exception e)
> {
> System.out.println(e);
> }
> }
> }
>
>