When uploading images using jsp, you can directly change the java code to jsp. The following exception occurs during the upload: 8:59:21 org. apache. catalina. core. serious StandardWrapperValve invoke: Servlet. service () for servlet jsp threw exceptionjava. io. IOException: Stream closed... think twice about the code after turning jsp into servlet. As follows (very eye-catching ):...} catch (Exception e) {e. printStackTrace ();} finally {out. flush (); // out. close (); // This is the source code DBHelper. freeConnection (connection);} out. write ('\ R'); // As shown above, the out object is still in use, so the exception out as described at the beginning is generated. write ('\ n');} catch (Throwable t) {if (! (T instanceof SkipPageException) {out = _ jspx_out; if (out! = Null & out. getBufferSize ()! = 0) try {out. clearBuffer ();} catch (java. io. IOException e) {} if (_ jspx_page_context! = Null) _ jspx_page_context.handlePageException (t) ;}} finally {_ jspxFactory. releasePageContext (_ jspx_page_context );}... solution: change the code in red and bold in the program to: out. flush (); out = pageContext. pushBody (); // the description of this program is clearly stated in the doc. (Note the differences between the flush () and clear () methods, because different programs are required) abstract void flush () Flush the stream. abstract void clear () Clear the contents of the buffer. pageContext implements the abstract class JspContext. the method is pushBody (). save the current out object BodyContent pushBody () Return a new BodyContent object, save the current "out" JspWriter, and update the value of the "out" attribute in the page scope attribute namespace of the PageContext. public abstract class BodyContentextends JspWriterout built-in object