Hi, I am trying to send data partially to the browser. So I use flush() method in PrintWriter Object. This will work fine when the data to be send is more than some 100 characters. But if it 5-10 chars the flush is not sending the data at that moment.
Here if stringToPrint conatains more than 100 characters it is sending the data at that moment itself. But otherwise it is sending it later.
Any Idea about his. Thanjs in Advace.
[BSouther: Added UBB CODE tags] [ March 21, 2007: Message edited by: Ben Souther ]
I suspect that the servlet is indeed flushing the output stream. If this is the first time it is flushed, the buffer will send the response headers plus whatever you have written. However, on the web browser side, the browser can decide that it does not have enough to even try to show something and will just wait for more. Perhaps you should ensure that what you send makes good HTML sense.
What exactly is your requirement? If you need to progressively disclose parts of the page, you'll need to use a means that gives you more control over the process. flush() was never meant for that purpose.
20 seconds is a long time to hold a browser connection open.
An alternate technique would be to spawn a new thread for your long running process, and return a status page to the user right away. That page could refresh every n seconds until the process has finished.