Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

when PrintWriter.flush() is called

 
Edy Yu
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll assume that the servlet container will call the flush() or close() method sometime while serving a request to one servlet because we don't have to code close() or flush() in our code. Does anyone know when this "commit" happens?
Thanks in advcance ...
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally I always prefer to code an explicit out.close(). With earlier versions of Tomcat, this solved some mysterious blank pages, so ever since then I have used an explicit close(). I don't think you can depend on close being called automatically in servlets.
I know that the finalize methods for various java.io streams call close, so I suppose that garbage collection would eventually force it.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic