It has been almost 4 years since I posted this, but it is never too late to say thank you for all the discussion on this thread. I just happen to reference this with a colleague who was dealing with this IE specific issue and how it let me to post this question. http://support.microsoft.com/kb/323308
On Monday, May 25, 2009 8:21:32 AM UTC-4, Brian wrote: > > It seems about a 50/50 split in hello world examples of HttpServlet > out on the 'internets' as to whether or not to close the > ServletOutputStream or PrintWriter. NetBeans for example will put the > close() call in their new Servlet wizard by default. So does Oracle's > JDeveloper. But other tutorials/examples do not close it. > http://edocs.bea.com/wls/docs70/servlet/progtasks.html > > In my particular case not closing the ServletOutputStream solved an > 'odd behavior' bug in an application when running on HTTPS on a > somewhat 'black box' production environment that was using Oracle Web > Cache and several other pre and post processing technologies on each > request. But I have not been successful at articulating why not > closing the outputstream is the fix or verifying there are no other > consequences as a result of not closing the output stream. 99% of the > time it seems to matter little whether the close is there are not (e.g > every J2EE IDE I have tried), but in this case it did Any thoughts? > > public class HelloWorldServlet extends HttpServlet { > public void service(HttpServletRequest req, > HttpServletResponse res) > throws IOException > { > // Must set the content type first > res.setContentType("text/html"); > // Now obtain a PrintWriter to insert HTML into > PrintWriter out = res.getWriter(); > out.println("<html><head><title>" + > "Hello World!</title></head>"); > out.println("<body><h1>Hello World!</h1></body></html>"); > //QUESTION: close or not close: > //out.close(); > } > } > -- You received this message because you are subscribed to the Google Groups "Java Posse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/javaposse?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
