This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reasoning of response buffer manipulation

 
D Rog
Ranch Hand
Posts: 472
Linux Objective C Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can somebody provide useful examples when servlet set buffer size, flush and reset?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Bill
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic