Joke Collection Website - Public benefit messages - Preparation of JSP verification code

Preparation of JSP verification code

ServletOutputStream sos = response.getOutputStream();

: Get an output stream object

ImageIO.write(image, "jpeg", sos); < /p>

: Write the given picture to the specified stream of sos.

sos.close();

: Close the stream and output the stream at the same time. If this sentence is not added, the picture cannot be displayed.

out.clear();

out = pageContext.pushBody();

The above two sentences are required. It should be that the out object is the default output stream object in jsp. This object is called when each request is completed. The out object conflicts with the getOutputStream related to using streams in jsp pages. Therefore, the two sentences above must be added. Otherwise, an exception will be reported. (But you don’t need to do the above processing in servlet)