Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

out.flush() not working

Status
Not open for further replies.

tommycat2

Programmer
Nov 22, 2004
1
US
I have a piece of code which I am using for testing apache. Essentially i need it to print out partial results to the web page before the complete jsp page has finished executing. I used to use apache 1.3x and oracle-jsp engine and with this configuration it seemed to work as expected when using the out.flush() command.
Now that I have upgraded to tomcat 5.0.28 and apache 2.0 when I use out.flush() it has no effect and waits until all of the content for the page has been prepared before commiting it to the web browser.

Here is my test program:

<%@ page language="java" import="java.util.*, java.rmi.*" %>

<%
for (int i=0; i <20; i ++) {

out.println("i="+i+"\n<br>");
out.flush();

try {
Thread.sleep(500);
} catch (Exception ex) {

}
}
%>

thanks for any help
 
Try this before your loop:

for(int k=0; k<10; k++){
out.print("<!--1234567890-->");
}

I don't know why, but it runs. Perhaps it fills the browser buffer.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top