• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clarification on a spec statement

 
Aniket Patil
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSP specification says:

Data is sent to the response stream on buffer flushes for buffered pages, or on encountering the first content (beware of whitespace) on unbuffered pages.

1)If the setBufferSize() method is not used, are pages buffered by default?

2)I assume, for buffered pages, a call to flush() commits the reponse. If the page is unbuffered, does an out.println() commit the response (referring to "or on encountering the first content" above)?

3)What does "beware of whitespace" imply?
[ February 26, 2007: Message edited by: Aniket Patil ]
 
Gabriel Forro
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Aniket,

The answers are as follows:
1. Yes, there is a default buffering. According to the JSP spec (page 50):

The default is buffered with an implementation buffer size of
not less than 8kb.


It means that the exact buffer size is implementation dependent (it can vary from vendor to vendor)
2. Yes it does
3. The part you quoted is from the "Dynamic content type" section of the JSP specification. The whole quote:

Dynamic setting of content type relies on an underlying invocation on response.setContentType(). That method can be invoked as long as no content has been been sent to the response stream. Data is sent to the response stream on buffer flushes for buffered pages, or on encountering the first content (beware of whitespace) on unbuffered pages.


Imagine that You switched off the buffering. In this case a whitespace which is placed just before the dynamic content commits/sends the response to the client. So You can not call the response.setContentType() any more! So You must beware of the whitespaces if You want to call the setContentType() method in an JSP page.
 
Aniket Patil
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Gabriel!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic