• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpServletResponse.getWriter

 
Hendy Setyo Mulyo
Ranch Hand
Posts: 219
Firefox Browser Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,

I have a question. Normally, we are getting the PrintWriter object from HttpServletResponse using HttpServletResponse.getWriter() method. I wonder whether the PrintWriter object returned by the method is in 'autoflush' mode or not? Is this mode considered container-specific?
Thanks.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, the PrintWriter obtained via ServletResponse has no idea of autoFlush. autoFlush is for a JspWriter's output object. The API of JspWriter gives you a hint :
If the page is not buffered, output written to this JspWriter object will be written through to the PrintWriter directly, which will be created if necessary by invoking the getWriter() method on the response object. But if the page is buffered, the PrintWriter object will not be created until the buffer is flushed and operations like setContentType() are legal. Since this flexibility simplifies programming substantially, buffering is the default for JSP pages.
 
Hendy Setyo Mulyo
Ranch Hand
Posts: 219
Firefox Browser Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool. Thanks Satou for your explanation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic