• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is it necessary to say "out.close()" in servlet code?

 
Tony Pacific
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Normally in servlet code, for service(), doGet(), or doPost() methods, we have:
PrintWriter out = res.getWriter();
// use out to write HTML
out.close();
But is it a must to say out.close()?
What if I don't?
A WebSphere book says "the web application server automatically closes the PrintWriter when the service method exits." I wonder if that is vendor dependent, or all J2EE-compliant servers are required to do so.
Can someone let me know?
Thank you in advance!
Tony
 
Sajee Joseph
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,
Its is better that u use out.close(), coz not all application servers will do that for u
...saj
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic