HttpServletResponse Interface
go on ..... Gnawing << Unique Architecture: Java Web Development application >> Good memory is better than bad writing. Make notes, deepen impressions.
A. Status line
Generate Status Response code
The 1.setStatus method can set the status code of any HTTP response message and generate a response status line.
2.sendRedirect Method Response Status Code 302
3.sendError method used to send the error message status code
Two. Response message header
Set the response message header (the response message header consists of field and field values)
The 1.addHeader and SetHeader methods are used to set all fields of the HTTP response message header
2.addIntHeader and Setintheader methods specifically set integer field values
3.addDateHeader and Setdateheader methods set Date field values
The 4.setContentType method is used to set the MIME type of the servlet's response body (the value of the Content-type field for the HTTP protocol)
5..setCharacterEncoding method Set the character set portion of the Content-type field
6.setContentLength method sets the size of the body (in bytes) (File size value)
The 7.containsHeader method is used to detect whether a field name exists in the response message header
Three. Response body
The 1.getWriter method is used to return a character output stream object created by the servlet engine
The response body is easily returned to the client, and the response body is also automatically converted based on the character encoding format specified by the Content-type of the response message header, and the object response body encoding must be set charset before the Getwriter method is called, otherwise it cannot be encoded correctly.
The 2.getOutputStream method is used to return a byte output stream object created by a servlet engine
The Getoutputstream method returns a Servletoutputstream object
A. You can return any response body (including image, video, and other binary data) through this object
B. can also return character text response body
Another day has passed. Go ahead!!! Every day we take a few steps forward, we will be more and more close to the dream!!! Ha ha
HttpServletResponse-------Brain Stump Note 2