You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Bill Neuman <bi...@hotmail.com> on 2002/02/15 00:01:17 UTC
Getting Apache to Stop Buffering my Servlet Output
All,
This is a question that has been repeated several times on this mailing
list, but as far as I can tell never answered.
I have a long back-end process during which I want to return interim results
to the browser. With a JSP, the standard way to do this seems to be to use
out.flush() at any point where I want to return partial results. This works
great when I browse tomcat's own web server (port 8080), but when I browse
the same page served through Apache (port 80 for me) and serviced by Tomcat,
The results all appear at once, rather than as I flush() them.
So, it appears Apache is adding some level of response buffering that I'm
not asking it to do. Does anybody know how to make this work.
Below is the code for a jsp page that demonstrates the issue--all help is
appreciated.
---BEGIN CODE---
<%@page language="java" session="false"%>
<html>
<head><title>Delaying</title></head>
<body>
<h2>Delaying...</h2>
The following lines should appear at approx.1 second intervals.
When served through Tomcat's own server (i.e. 8080) it works.
When served through Apache using Tomcat as the handler, the page all
appears at once after an approx. 5 second delay.
<p>
<%
out.flush();
long delay = 1000;
long start = System.currentTimeMillis();
for (int ii = 1; ii < 6; ii++) {
while (System.currentTimeMillis() < start + delay) {
}
start = System.currentTimeMillis();
%>
Delayed a total of <%= ii %> intervals. Pretend this is a message
giving status on task execution in a long string of tasks.<br>
<%
System.out.print(" ii=" + ii + "; ");
out.flush();
}
System.out.println("");
%>
</body>
</html>
---END CODE---
Regards,
Bill Neuman
_________________________________________________________________
Join the worlds largest e-mail service with MSN Hotmail.
http://www.hotmail.com
--
To unsubscribe: <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>