Meaningless Drivel is fun!
The moose likes Servlets and the fly likes response flush & close... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "response flush & close..." Watch "response flush & close..." New topic

response flush & close...

Dave Brown
Ranch Hand

Joined: Mar 08, 2005
Posts: 301
Hi all,

Just wondering about the relevance of response.flush() and close();

Does it help the servlet container/client browser behave by ensuring you have a flush() or a close() after a servlet has done its main business?



Regards, Dave Brown
SCJP 6 - [url][/url] - Check out Grails Forum
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

I think it is best to let the container handle the stream unless you have a good reason to intervene.
[ December 14, 2005: Message edited by: Bear Bibeault ]

[Asking smart questions] [About Bear] [Books by Bear]
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3753

There is an autoFlush attribute you can set on the page context to handle this.

In general, though, you only call flush() if you need to send user data during a long running process that has not completed yet. Other than that, you don't have to worry about it.

[OCA 8 Book] [Blog]
I agree. Here's the link:
subject: response flush & close...
It's not a secret anymore!