I am using a ServletOutputStream in my doPost method obtained via response.getOutputStream(). Should we call close() on it at the end of the doPost/doGet method? I remember reading somewhere that we should not call close() on a ServletOutputStream and instead only call flush().
My experience is that sometimes the container can behave in strange ways, and I have, in deperation, explicitly closed or flushed the output stream, but technically, you shouldn't close it, and I get the impression that flush() may be being overused as well. However, calling close() on an already closed stream is supposed to have no effect, so the fact that BOTH you and the container close the stream is - in theory - OK. In practice, you are living dangerously, since the container might conceivably find a reason to put something in the stream AFTER you exit the servlet method.
An IDE is no substitute for an Intelligent Developer.