Remy,

I also tried using a PrintWriter, and i got the same results. checkError() only returns true when about 8k of data are sent after the connection has been closed.

You said that there was indeed something wrong... I'm using Tomcat 5.0.16 , do you know if this version has already been fixed?

Well, after some tests, i think that i found the source of my problem. The method response.setBufferSize(), only allows me to set a buffer higher than 8192 bytes. If i try to set a lower value it just ignores it and keep the default of 8192. I confirmed this with:

response.setBufferSize(n);
System.out.println("BufferSize="+response.getBufferSize); // if n<8192 it aways prints 8192, otherwise print the value of n


I still would like to know if there's any way (ugly or not, it doesn't matter how) to disable this buffering... So i can detect when the client closes the connection.

thanks for your time!
Vitor

Remy Maucherat wrote:

Vitor Buitoni wrote:

What do you mean by ok?

As far as i can see, the connection closes and writing data to the OutputStream should generate an IOException, but this isn't happening... :-(
The problem is that my servlet is inside a loop, and needs to know when the client closes the connection, so it can exit the loop and properly close the running thread and liberate memory and cpu resources.


If you say it's ok, it means that tomcat really buffers the data and only generate the IOException when this buffer is full, and that this behavior is ok.
Is there any way i can control this tomcat's behaviour, like reduce the size of the buffer? Or even disable this buffer? (better)


thanks!
Vitor
P.S.: (to avoid confusion) The original message was posted by Paulo, but i'm working with him.


There was indeed something wrong. This has been fixed.

out.write(s.getBytes(), 0, s.length());


Writing that kind of code is bad ! You should likely use a PrintWriter instead and use checkError.





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to