You should not close the stream. The servlet container will automatically close the stream after the servlet is finished running as part of the servlet request life-cycle.