aspose file tools*
The moose likes Servlets and the fly likes cleared, commited and flushed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "cleared, commited and flushed" Watch "cleared, commited and flushed" New topic
Author

cleared, commited and flushed

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
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.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

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

Joined: Oct 11, 2004
Posts: 3830
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

Joined: Mar 06, 2001
Posts: 13459

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

Joined: Oct 11, 2004
Posts: 3830
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

Joined: Mar 06, 2001
Posts: 13459

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
Nikhil Goel
Ranch Hand

Joined: Jul 11, 2003
Posts: 32
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

Joined: Oct 11, 2004
Posts: 3830
Thank you very mcuh David and Nikhil.
I was really very nice explaination.

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
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
 
 
subject: cleared, commited and flushed