You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Fabio Rossi <pa...@yahoo.it> on 2007/07/02 10:49:13 UTC

Unable to disable output buffering

Hello.

I need to disable output stream buffering. I tried with response.setBufferSize but i noticed that Tomcat does not permit to set a level lower than the standard 8k.
Then I read that the solution is to specify the connector property socketBuffer="-1" in server.xml but again, it does not work for me. If I print the current buffer size during the execution of the servlet I get again the same 8192.

How can I do do disable output buffering? I need that an exception is raised even if the client fails to read the last byte of the stream...and with output buffering it's not possibile.

Please help. Thank you.
       
---------------------------------

---------------------------------
L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail

Re: Unable to disable output buffering

Posted by Fabio Rossi <pa...@yahoo.it>.
No. I tried it but it seems to have no effect.
..and if i call getBufferSize() in my code I still get the default value of 8K even if I set the socketBuffer=-1 connector property in the server.xml

Filip Hanik - Dev Lists <de...@hanik.com> ha scritto: does calling response.flushBuffer not do anything for you?

Filip

Fabio Rossi wrote:
> Hi, thank you for the answer, but my problem in different.
> When I send the data, I specify the content lenght and the client knows if the "download" is completed or not.
>
> The problem is that, with output buffering, if the client crashes, for example, after it has downloaded 1MB of a 4MB file, the servlet noticed the crash (an exception is raised).
>
> The problem is that, if the client crash when it has downloaded almost all the data, the servlet doesn't notice the crash beacuse it has written correctly in the buffer, even if the real write to the client cannot succed. It' s not easy for me to explain that very well in english, but my problem is the same as the one posted here:
>
> http://mail-archives.apache.org/mod_mbox/tomcat-users/200401.mbox/%3C3FFD4EF2.2070401@digitro.com.br%3E
>
> So i tried using socketBuffer=-1 in the connector properties (server.xml) but it doesn't work anyway.
>
> Thank you.
>
> Johnny Kewl  ha scritto: 
> Fabio, it just sounds all wrong....
> I have a sneaky suspicion that if you made the buffer very large, your 
> problems will fix themselves, but thats still not the solution.
> I actually think you are not telling the client the size of the data.... do 
> you set
>         response.setContentLength("How Big");
> anywhere?
>
> I forget all the details, but its something like this...
> If you dont set the size.... TC will drop the connection when the data is 
> sent, the old HTTP spec.
> If the data is massive with no size, TC will start chunking, and the client 
> has to wait for that last special char, to know its done.
> If it all fits into the buffer, TC will create the headers, because it can 
> see all the data.... and that will probably fix it, but its just luck.
>
> But if you give it the size.... the client will know how much data is 
> coming, and wait for it.... so if the browser sits there waiting forever, 
> you know theres something wrong, like the servlet isnt sending all the data, 
> ie header size is greater than actual data sent.
>
> I just think you should give the client enuf info to decide for itself.... 
> theres alot of internet between server and client, if something crashes, 
> client should still be able to say, hey user you need to refresh.... I think 
> its the only way.
>
> Why wont the above work?... maybe you should post your code...
>
> ----- Original Message ----- 
> From: "Fabio Rossi" 
>
> To: 
> Sent: Monday, July 02, 2007 10:49 AM
> Subject: Unable to disable output buffering
>
>
>   
>> Hello.
>>
>> I need to disable output stream buffering. I tried with 
>> response.setBufferSize but i noticed that Tomcat does not permit to set a 
>> level lower than the standard 8k.
>> Then I read that the solution is to specify the connector property 
>> socketBuffer="-1" in server.xml but again, it does not work for me. If I 
>> print the current buffer size during the execution of the servlet I get 
>> again the same 8192.
>>
>> How can I do do disable output buffering? I need that an exception is 
>> raised even if the client fails to read the last byte of the stream...and 
>> with output buffering it's not possibile.
>>
>> Please help. Thank you.
>>
>> ---------------------------------
>>
>> ---------------------------------
>> L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail 
>>     
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
>
>        
> ---------------------------------
>
> ---------------------------------
> L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail
>   
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition. 
> Version: 7.5.476 / Virus Database: 269.9.14/883 - Release Date: 7/1/2007 12:19 PM
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



       
---------------------------------

---------------------------------
L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail

Re: Unable to disable output buffering

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
does calling response.flushBuffer not do anything for you?

Filip

Fabio Rossi wrote:
> Hi, thank you for the answer, but my problem in different.
> When I send the data, I specify the content lenght and the client knows if the "download" is completed or not.
>
> The problem is that, with output buffering, if the client crashes, for example, after it has downloaded 1MB of a 4MB file, the servlet noticed the crash (an exception is raised).
>
> The problem is that, if the client crash when it has downloaded almost all the data, the servlet doesn't notice the crash beacuse it has written correctly in the buffer, even if the real write to the client cannot succed. It' s not easy for me to explain that very well in english, but my problem is the same as the one posted here:
>
> http://mail-archives.apache.org/mod_mbox/tomcat-users/200401.mbox/%3C3FFD4EF2.2070401@digitro.com.br%3E
>
> So i tried using socketBuffer=-1 in the connector properties (server.xml) but it doesn't work anyway.
>
> Thank you.
>
> Johnny Kewl <jo...@kewlstuff.co.za> ha scritto: 
> Fabio, it just sounds all wrong....
> I have a sneaky suspicion that if you made the buffer very large, your 
> problems will fix themselves, but thats still not the solution.
> I actually think you are not telling the client the size of the data.... do 
> you set
>         response.setContentLength("How Big");
> anywhere?
>
> I forget all the details, but its something like this...
> If you dont set the size.... TC will drop the connection when the data is 
> sent, the old HTTP spec.
> If the data is massive with no size, TC will start chunking, and the client 
> has to wait for that last special char, to know its done.
> If it all fits into the buffer, TC will create the headers, because it can 
> see all the data.... and that will probably fix it, but its just luck.
>
> But if you give it the size.... the client will know how much data is 
> coming, and wait for it.... so if the browser sits there waiting forever, 
> you know theres something wrong, like the servlet isnt sending all the data, 
> ie header size is greater than actual data sent.
>
> I just think you should give the client enuf info to decide for itself.... 
> theres alot of internet between server and client, if something crashes, 
> client should still be able to say, hey user you need to refresh.... I think 
> its the only way.
>
> Why wont the above work?... maybe you should post your code...
>
> ----- Original Message ----- 
> From: "Fabio Rossi" 
>
> To: 
> Sent: Monday, July 02, 2007 10:49 AM
> Subject: Unable to disable output buffering
>
>
>   
>> Hello.
>>
>> I need to disable output stream buffering. I tried with 
>> response.setBufferSize but i noticed that Tomcat does not permit to set a 
>> level lower than the standard 8k.
>> Then I read that the solution is to specify the connector property 
>> socketBuffer="-1" in server.xml but again, it does not work for me. If I 
>> print the current buffer size during the execution of the servlet I get 
>> again the same 8192.
>>
>> How can I do do disable output buffering? I need that an exception is 
>> raised even if the client fails to read the last byte of the stream...and 
>> with output buffering it's not possibile.
>>
>> Please help. Thank you.
>>
>> ---------------------------------
>>
>> ---------------------------------
>> L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail 
>>     
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
>
>        
> ---------------------------------
>
> ---------------------------------
> L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail
>   
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition. 
> Version: 7.5.476 / Virus Database: 269.9.14/883 - Release Date: 7/1/2007 12:19 PM
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Unable to disable output buffering

Posted by Fabio Rossi <pa...@yahoo.it>.
Hi, thank you for the answer, but my problem in different.
When I send the data, I specify the content lenght and the client knows if the "download" is completed or not.

The problem is that, with output buffering, if the client crashes, for example, after it has downloaded 1MB of a 4MB file, the servlet noticed the crash (an exception is raised).

The problem is that, if the client crash when it has downloaded almost all the data, the servlet doesn't notice the crash beacuse it has written correctly in the buffer, even if the real write to the client cannot succed. It' s not easy for me to explain that very well in english, but my problem is the same as the one posted here:

http://mail-archives.apache.org/mod_mbox/tomcat-users/200401.mbox/%3C3FFD4EF2.2070401@digitro.com.br%3E

So i tried using socketBuffer=-1 in the connector properties (server.xml) but it doesn't work anyway.

Thank you.

Johnny Kewl <jo...@kewlstuff.co.za> ha scritto: 
Fabio, it just sounds all wrong....
I have a sneaky suspicion that if you made the buffer very large, your 
problems will fix themselves, but thats still not the solution.
I actually think you are not telling the client the size of the data.... do 
you set
        response.setContentLength("How Big");
anywhere?

I forget all the details, but its something like this...
If you dont set the size.... TC will drop the connection when the data is 
sent, the old HTTP spec.
If the data is massive with no size, TC will start chunking, and the client 
has to wait for that last special char, to know its done.
If it all fits into the buffer, TC will create the headers, because it can 
see all the data.... and that will probably fix it, but its just luck.

But if you give it the size.... the client will know how much data is 
coming, and wait for it.... so if the browser sits there waiting forever, 
you know theres something wrong, like the servlet isnt sending all the data, 
ie header size is greater than actual data sent.

I just think you should give the client enuf info to decide for itself.... 
theres alot of internet between server and client, if something crashes, 
client should still be able to say, hey user you need to refresh.... I think 
its the only way.

Why wont the above work?... maybe you should post your code...

----- Original Message ----- 
From: "Fabio Rossi" 

To: 
Sent: Monday, July 02, 2007 10:49 AM
Subject: Unable to disable output buffering


> Hello.
>
> I need to disable output stream buffering. I tried with 
> response.setBufferSize but i noticed that Tomcat does not permit to set a 
> level lower than the standard 8k.
> Then I read that the solution is to specify the connector property 
> socketBuffer="-1" in server.xml but again, it does not work for me. If I 
> print the current buffer size during the execution of the servlet I get 
> again the same 8192.
>
> How can I do do disable output buffering? I need that an exception is 
> raised even if the client fails to read the last byte of the stream...and 
> with output buffering it's not possibile.
>
> Please help. Thank you.
>
> ---------------------------------
>
> ---------------------------------
> L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org




       
---------------------------------

---------------------------------
L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail

Re: Unable to disable output buffering

Posted by Johnny Kewl <jo...@kewlstuff.co.za>.
Fabio, it just sounds all wrong....
I have a sneaky suspicion that if you made the buffer very large, your 
problems will fix themselves, but thats still not the solution.
I actually think you are not telling the client the size of the data.... do 
you set
        response.setContentLength("How Big");
anywhere?

I forget all the details, but its something like this...
If you dont set the size.... TC will drop the connection when the data is 
sent, the old HTTP spec.
If the data is massive with no size, TC will start chunking, and the client 
has to wait for that last special char, to know its done.
If it all fits into the buffer, TC will create the headers, because it can 
see all the data.... and that will probably fix it, but its just luck.

But if you give it the size.... the client will know how much data is 
coming, and wait for it.... so if the browser sits there waiting forever, 
you know theres something wrong, like the servlet isnt sending all the data, 
ie header size is greater than actual data sent.

I just think you should give the client enuf info to decide for itself.... 
theres alot of internet between server and client, if something crashes, 
client should still be able to say, hey user you need to refresh.... I think 
its the only way.

Why wont the above work?... maybe you should post your code...

----- Original Message ----- 
From: "Fabio Rossi" <pa...@yahoo.it>
To: <us...@tomcat.apache.org>
Sent: Monday, July 02, 2007 10:49 AM
Subject: Unable to disable output buffering


> Hello.
>
> I need to disable output stream buffering. I tried with 
> response.setBufferSize but i noticed that Tomcat does not permit to set a 
> level lower than the standard 8k.
> Then I read that the solution is to specify the connector property 
> socketBuffer="-1" in server.xml but again, it does not work for me. If I 
> print the current buffer size during the execution of the servlet I get 
> again the same 8192.
>
> How can I do do disable output buffering? I need that an exception is 
> raised even if the client fails to read the last byte of the stream...and 
> with output buffering it's not possibile.
>
> Please help. Thank you.
>
> ---------------------------------
>
> ---------------------------------
> L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org