• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

the puzzle of setBufferSize() in JSP

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
The harder I work, the luckier I get. -Sam Goldwyn So tiny. - this ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic