File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes When is a response committed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "When is a response committed" Watch "When is a response committed" New topic

When is a response committed

Nila dhan
Ranch Hand

Joined: Sep 15, 2005
Posts: 161
I am not sure if my question is correct or incorrect.When is a response committed?I mean under what circumstances?
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3753

If by committed you mean sent to the user, it happens at the end of a servlet call or if a flush() of the output stream is invoked.

One common use of flush() is to output data to the screen for the user to see before a long process is complete, such as a task that would require the user to wait 5 minutes. Its preferable to give them an update status during that 5 minutes than having them watch a screen that just says 'loading'.

[OCA 8 Book] [Blog]
Nila dhan
Ranch Hand

Joined: Sep 15, 2005
Posts: 161
The response is also committed when the buffer gets filled if i am right.
Are there any other cases when a response is committed without calling flush or forwarding the response?
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Nila, you are correct. If in the process of writing to the response the buffer gets full, it will be implicitly flushed.

So much trouble in the world -- Bob Marley
I agree. Here's the link:
subject: When is a response committed
It's not a secret anymore!