HTTP response Processing

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.