Software 152 Roger
1. HTTP Response content:
A) Response status: Status code and status information composition
I. Status code:
1.1XX: Specifies certain actions that the client should respond to
2.2XX: Used to indicate a successful request; For example, 200 means complete
3.4XX: Used to indicate a client error, for example 404 indicates that the requested document does not exist
4.5XX: User support server error, generally refers to Java code internal error
b) Response Head:
I Response type
ii Character encoding
iii Cookies
c) Response body: Text type and binary type
2. Java EE to object (javax.servlet.http.HttpServletResponse)
A) Method:
I. Set the response status code
1. SetStatus () send a custom status code or message to the client
2. Senderror () sends the specified error message code to the client
II Set the header
1. SetHeader () sends the response hair of the specified name and value (character type or integer constant) to the client
2. Setdataheader () sends the response hair of the specified name and value (long type) to the client
III A convenient way to set the response header
1. setContentType () directly set to the Content Type MIME response header
2. Setcontentlength () Sets the length of the body, in bytes
3. Setcharacterencoding () sets the character set
4. Setbuffersize () Sets the number of cache bytes to the response body
IV setting the method of sending a function to the body
1. setContentType () Set the response type ContentType
2. Setcharacterencoding () set the character encoding
3. PrintWriter Out=response.getwriter () gets the text character stream object
4. OUT.PRINTLN () sending text data to a Stream object
5. Out.flush () Empty the cached characters in the stream
6. Out.close () Close the stream
7. Addcookie () Send cookie to client
8. Sendredirect () redirect Response
9. InputStream in=response.getinputstream () get binary stream
HTTP response Processing