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

Reasoning of response buffer manipulation

D Rog
Ranch Hand

Joined: Feb 07, 2004
Posts: 472

Can somebody provide useful examples when servlet set buffer size, flush and reset?

Retire your iPod and start with HD Android music player Kamerton | Minimal J2EE container is here | Light weight full J2EE stack | and build tool | Co-author of "Windows programming in Turbo Pascal"
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
Buffer size - the default is usually good

flush() - do this after you have written some output and are about to start a process that may be time consuming or may fail. This ensures that the user sees something instead of a blank screen. Also do a flush after you are sure all output has been written.

reset() - pretty tricky - this allows you to completely change the response headers and any body in the buffer - BUT could easily throw an IllegalStateException. I would consider reset() a symptom of bad design. If you think you need to use reset, its time to back off and rethink your architecture.

I agree. Here's the link:
subject: Reasoning of response buffer manipulation
jQuery in Action, 3rd edition