• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

cleared, commited and flushed

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does exactly these mean:

1] response is cleared
2] response is commited
3] response is flushed

I think, cleared means, now there is nothing written in the writer of response (out).

Commited means, now writer is locked, if you will try to write anything then will get an IllegalStateException.

Flushed is same as commited but by name it looks like cleared.

Are all coorect or rather any of these is correct???

Thanks.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Committed means it has sent information to the client and may not be storing information in the buffer. You can still write to the stream, but if you try to clear it you will get an IllegalStateException.

Flushed means you have pushed the information from the buffer to the client and the buffer will therefore be empty till you write something new to it. The response is now also committed.
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by David O'Meara:
Committed means it has sent information to the client and may not be storing information in the buffer. You can still write to the stream, but if you try to clear it you will get an IllegalStateException.

Flushed means you have pushed the information from the buffer to the client and the buffer will therefore be empty till you write something new to it. The response is now also committed.



Then, what is the difference?

In both the cases, information is sent to the client, buffer is empty, you can weite in it, you can't clear buffer now...



Thanks.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Flushing commits the response, but a response can be committed without flushing if it fills first. In either case it can no longer be cleared.
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by David O'Meara:
Flushing commits the response, but a response can be committed without flushing if it fills first. In either case it can no longer be cleared.



if it fills first, what this line means?

Thanks a lot.

 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You write information to a stream, but the stream may be buffered, meaning that it caches or holds onto data rather than writing each piece as you pass it to the stream. This has several advantages but amoung them it is more efficient and it allows you to clear the information if the buffer hasn't sent it yet.

Buffers normally have a fixed size, usually defined when the buffer is created. Once the buffer fills it sends the data, clears the buffer and starts buffering the next piece of the response.

If a buffer is holding information and you tell it to flush then it will also send the data to the client, clear itself, and start again.

Hence two ways of sending data from the buffer to the client:
1) fill the buffer
2) flush the buffer
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is what it means

Flush --->Forces any content in the buffer to be written to the client. A call to this method automatically commits the response, meaning the status code and headers will be written. Practically means flushing to browser . User can view the response.

Committed->Means already response headers & status code are written and you can't modify them .

Buffer - Means still you can add more to the response before comitting and finally flushing it .
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very mcuh David and Nikhil.
I was really very nice explaination.

 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by David O'Meara:
You write information to a stream, but the stream may be buffered, meaning that it caches or holds onto data rather than writing each piece as you pass it to the stream. This has several advantages but amoung them it is more efficient and it allows you to clear the information if the buffer hasn't sent it yet.

Buffers normally have a fixed size, usually defined when the buffer is created. Once the buffer fills it sends the data, clears the buffer and starts buffering the next piece of the response.

If a buffer is holding information and you tell it to flush then it will also send the data to the client, clear itself, and start again.

Hence two ways of sending data from the buffer to the client:
1) fill the buffer
2) flush the buffer



Hence two ways of sending data from the buffer to the client:
1) fill the buffer - commiting the response
2) flush the buffer - flushing the response
 
Switching from electric heat to a rocket mass heater reduces your carbon footprint as much as parking 7 cars. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic