Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

the puzzle of setBufferSize() in JSP  RSS feed

 
Wei Geng
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote a JSP page in which I tried to call response.setBufferSize() after the data was written into the OutStream Object.
As the specification of Servlet said, once the data was written into the outputstream object, the call to setBufferSize() will cause Exception.
But in my try-catch block, nothing was caught.


I was puzzled that why did setBufferSize() not cause Exception after the data was written into the output object?

Any help will be greatly appreciated.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A JSP page is using buffering. As long as the buffer as not been flushed, no data is actually written.
Try to call out.flush() before setting the buffer size, and you'll get an exception.
 
Wei Geng
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Satou kurinosuke:
A JSP page is using buffering. As long as the buffer as not been flushed, no data is actually written.
Try to call out.flush() before setting the buffer size, and you'll get an exception.


As you said, the Exception will be thrown out after out.flush().
However, what led to this result is the commit of response.
The following code can prove it:


isCommited() can prove that the response was not commited. However the setBufferSize() cause Exception either.
[ July 21, 2006: Message edited by: Wei GENG ]
 
Wei Geng
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I suppose that the response will not be sent to the browser, until the output object was flushed explicitly or automatically. So setBufferSize() may cause Exception once the data was written into the output object, but not only after the response was committed.
 
Wei Geng
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If my opinion is correct, why the Exception did not appear in the JSP in which case I called setBufferSize() after writing the text into the output object?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!