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

Buffer, Buffer! How good a size should you be?

 
boyet silverio
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't really fully understand how the 'buffer' value is best set when used in jsp pages. What are factors to consider in changing the default buffer size? I noticed that buffer='none' is even an option. When is this used? Thanks in advance for any comments?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The default value is 8k.
In most cases that I've seen people wanting to alter this value, it has been better to redesign the page rather than try to decide on a new value.
The main use of the Buffer is to allow you to output data to the client and then change your mind. A better decision would be to decide what you want to output before you start sending it.
It also comes in handy when an exception is thrown while a page is being sent. In this case, if the buffer hasn't filled yet, it is cleared and the user is sent to the error page. If the response has already been comitted because the Buffer has been sent, the error page may or may not be sent as well. It shouldn't be sent, but some servers do still send it. In this case it would again be preferable to protect against exceptions rather than making the buffer larger to handle this condition.
Hope this helps.
Dave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic