Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Response commitment for buffered and unbuffered pages

 
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.


In the following code:

I am setting the buffer size to 0, which should be equivalent to an unbuffered page. Next i try to print "This is the right code " to the browser, which acc. to the spec statement above, should be flushed immediately on encountering the first println() for unbuffered pages. After that, i attempt to forward to result.jsp.

There is no IllegalStateException thrown, not even in console, even though i am trying to forward after committing the response. Secondly, instead of "This is the right code " getting printed to the browser (since the page is unbuffered), the browser gets forwarded to result.jsp, which is unexpected. With an out.flush(), "This is the right code " gets printed, but a flush() shouldn't be necc for unbuffered pages.

Please clarify when a response gets committed and why the code above exhibits such behavior.

[ March 13, 2007: Message edited by: Aniket Patil ]
[ March 13, 2007: Message edited by: Aniket Patil ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic