Oops - I tried to use Hotmail to post because my primary ISP's mail
server is down, and it mangled my JSP page. So I'll repeat the
question...
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---
P.S. I've also tried request.flushBuffer() based on responses
to one of the previous questions about this, but that is even
worse--if I use it, the "chunked" behavior doesn't even
work when browsing Tomcat's own web server.
Regards,
Bill Neuman
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>