Detailed http status codes used

100-199 is used to specify some of the client should be the appropriate action.
200-299 used to represent the request was successful.
300-399 for a file has been moved and is often included in the Location header is specified in the new address information.
400-499 is used to indicate a client error.
500-599 to support server error.

HttpServletResponse associated with the different representatives of the constants in the standard message of status code. In the servlet program, you will use more of the identity of these constants to use status code. For example: you will use the response.setStatus (response.SC_NO_CONTENT) rather than response.setStatus (204), because the latter is not easy to understand and prone to error. However, you should notice that the server allows minor changes to the message, the client only pay attention to status code numeric value. So the server may not only return HTTP/1.1 200 HTTP/1.1 200 OK.

100 (Continue / Continued)
If the server receives the header information in the request with a 100-continue, which means the client asked if the request can be sent in the following attachment. In this case, the server uses 100 (SC_CONTINUE) allows the client to continue or 417 (Expectation Failed) tell the client not accept attachments. This status code is new in HTTP 1.1.

101 (Switching Protocols / Conversion Agreement)
101 (SC_SWITCHING_PROTOCOLS) status code means the server header information in accordance with its changes on a different protocol. This is new in HTTP 1.1.

200 (OK / normal)
200 (SC_OK) means everything is normal. GET and POST are generally used for the corresponding request. This status code of the servlet is the default; If you do not call the setStatus method, it would be 200.

201 (Created / created)
201 (SC_CREATED) that the server's response to the request to create a new document; Location header should be given its URL.

202 (Accepted / accepted)
202 (SC_ACCEPTED) tells the client requests are being implemented, but not processed.

203 (Non-Authoritative Information / non-official information)
Status code 203 (SC_NON_AUTHORITATIVE_INFORMATION) is said to return the document to be normal, but because you are using a copy of the document so some information may be incorrect response header. This is new in HTTP 1.1.

204 (No Content / Content)
In the new document is not the case, 204 (SC_NO_CONTENT) to ensure that the browser continues to display the previous document. This is the status code for the user periodically reload a page very useful, and you can determine whether the previous page has been updated. For example, a servlet might be as follows:
int pageVersion = Integer.parseInt (request.getParameter ("pageVersion"));
if (pageVersion>; = currentVersion) {
response.setStatus (response.SC_NO_CONTENT);
} Else {
/ / Create regular page
However, this method response header information or by refreshing the equivalent of the HTML tags are automatically reload the page work, because it will return a 204 status code to stop after the overload. However, JavaScript scripts based on automatic overload in this case still need to be able to work. Can read the book 7.2 (HTTP 1.1 Response Headers and Their Meaning / HTTP 1.1 response headers and their meaning) of a detailed discussion.

205 (Reset Content / Reset content)
Reset Content 205 (SC_RESET_CONTENT) means that although no new document but the browser to reset the document display. This status code is used to force browser to clear form fields. This is new in HTTP 1.1.

206 (Partial Content / local content)
206 (SC_PARTIAL_CONTENT) is completed on the server that contains the local Range request header is sent. This is new in HTTP 1.1.

300 (Multiple Choices / multiple choice)
300 (SC_MULTIPLE_CHOICES) that the requested documents can be found in many places and will return the documents listed. If the server has a preferred setting, the first option will be listed in the Location response header information.

301 (Moved Permanently)
301 (SC_MOVED_PERMANENTLY) state that the requested document is elsewhere; document will locate the new URL given in response header. Browser will automatically connect to the new URL.

302 (Found / Found)
And 301 is somewhat similar, but in the Location header to the URL should be understood as temporary rather than permanent exchange of addresses. Note: In HTTP 1.0, the message is a temporary move (Moved Temporarily) and not be found, so the constant is SC_MOVED_TEMPORARILY HttpServletResponse not we think of SC_FOUND.

Note that the representative status code 302 instead of the constant is SC_MOVED_TEMPORARILY SC_FOUND.

Status code 302 is very useful because the browser automatically connected to the header information as given in response to the new URL. This is very useful, but there is a special method for this - sendRedirect. Using response.sendRedirect (url) than calling response.setStatus (response.SC_MOVED_TEMPORARILY) and response.setHeader ("Location", url) a few more benefits. First of all, response.sendRedirect (url) method is significantly simple and easy. Second, servlet automatically create a save this link to provide to those who can not automatically turn the browser. Finally, in the servlet 2.2 version (J2EE in the versions), sendRedirect able to handle relative path, automatically converted to an absolute path. But the 2.1 version you can only use absolute paths.

If you redirect the user to another page of the site, you use the method of HttpServletResponse in encodeURL send URL. To do so can prevent the continued use of URL rewriting for session tracking based on the situation. URL rewriting is a site you do not use cookies to track the user's way. This is the URL by the end of each additional path information to achieve, but the servlet session tracking API will automatically pay attention to these details. Session tracking in the ninth chapter, and will develop the habit of using encodeURL session tracking functionality added later much easier.

Core skills if you redirect the user to other pages of your site, using response.sendRedirect (response.encodeURL (url)) pre-planned way of session tracking (session tracking) than just call response.sendRedirect (url) Yes more.

This status code is sometimes used interchangeably with 301. For example, if you visited the wrong **host/ ~ user (path information is not complete), some servers will return status code 301, while others return 302. Technically, if the initial GET request is assumed the browser is automatically redirected. If you want more details, see the discussion of the status code 307.

303 (See Other / See Additional Information)
This status code and 301,302 similar to, but if the initial request was POST, then the new document (given in the Location header) medicinal GET back. This status code is new in HTTP 1.1.

304 (Not Modified / to correct)
When the client has a cache of documents, by providing an If-Modified-Since header that the client can only hope that the document has been modified after the specified date only when the overloaded this document, in this way can be conditional request. 304 (SC_NOT_MODIFIED) refers to the version of the buffer has been updated and the client should update the document. In addition, the server returns the requested document and the status code 200. servlet generally does not directly set the status code. They will realize getLastModified methods and default service based on the revised approach to date to request conditional. This method is part of the routine is 2.8 (An Example Using Servlet Initialization and Page Modification Dates / servlet initialization and a page with examples of the date of amendment) is given.

305 (Use Proxy / proxy)
305 (SC_USE_PROXY) that the requested documents through the Location header to the proxy server available. This status code is new in HTTP 1.1.

307 (Temporary Redirect / Temporary redirect)
Browser handles 307 and 302 the same as the rules state. 307 state is added to the HTTP 1.1 browser is receiving as many 302 response even if the original message is still the case for the implementation of POST wrong turn. Only 303 responses received only assume that the browser will redirect the POST request. This new status code to add the purpose is clear: according to time in response to 303 requests to GET and POST; and in accordance with the 307 response, instead of GET requests to POST requests. Note: For some reason not in the HttpServletResponse in constant corresponding to this state. This status code is new in HTTP 1.1.

Note that there is no SC_TEMPORARY_REDIRECT HttpServletResponse constant, so you can only use the 307 status code displays.

400 (Bad Request / Bad Request)
400 (SC_BAD_REQUEST) pointed out that the client requests the syntax error.

401 (Unauthorized / Unauthorized)
401 (SC_UNAUTHORIZED) said client without a valid Authorization header information as information access is password-protected pages. This response must include the authorization of a WWW-Authenticate header. For example, section 4.5 in the book "Restricting Access to Web Pages. / Restrict access to Web pages."

403 (Forbidden / prohibited)
403 (SC_FORBIDDEN) means that unless otherwise authorized by the server has refused to provide the requested resources. The state often damaged due to server caused the file or directory permission.

404 (Not Found / not found)
404 (SC_NOT_FOUND) state of each network programmers may have encountered, he told the address given by the client can not find any resources. It is said that "do not have the access page," the standard way. This status code is commonly used in the HttpServletResponse class to respond and have a special way to achieve it: sendError ("message"). Relative to the setStatus use sendError have several advantages: the server automatically generates an error page to display the error message. However, Internet Explorer 5 is the default browser error page ignore you to play and display the custom error page, although Microsoft did ** the HTTP specification. To turn off this feature, on the Tools menu, select Internet Options, enter the Advanced tab, and make sure "Show friendly HTTP error messages" option (in my browser is the last 8 of the option) has not been selected . But very few users know this option, so this feature is hidden and IE5 users can not see you back to the user. The other major browsers and IE4 are full display server-generated error page. Can refer to Figure 6-3 and 6-4 in the example.

By default, the core of warning, IE5 ignore server-generated error page.

405 (Method Not Allowed / method not allowed)
405 (SC_METHOD_NOT_ALLOWED) pointed out that the request method (GET, POST, HEAD, PUT, DELETE, etc.) are not allowed to use certain resources. This status code is new in HTTP 1.1.

406 (Not Acceptable / not accessible)
406 (SC_NOT_ACCEPTABLE) that the MIME type of requested resources and the client specified in the Accept header in the type of inconsistency. See the table in the book section 7.2 7.1 (HTTP 1.1 Response Headers and Their Meaning / HTTP 1.1 response headers and their meaning) in the introduction of the MIME type. 406 is new in HTTP 1.1.

407 (Proxy Authentication Required / proxy server authentication required)
407 (SC_PROXY_AUTHENTICATION_REQUIRED) and 401 state somewhat similar, but this state for the proxy server. The client must state that the authentication through a proxy server. Proxy server returns a Proxy-Authenticate response header information to the client, which will cause the client to use with the Proxy-Authorization request header information to reconnect. This status code is new in HTTP 1.1.

408 (Request Timeout / Request timeout)
408 (SC_REQUEST_TIMEOUT) refers to the server waits for the client sends a request for too long. This status code is new in HTTP 1.1.

409 (Conflict / conflict)
This status is usually used in conjunction with the PUT request, 409 (SC_CONFLICT) state is often used to try to upload the correct file version. This status code is new in HTTP 1.1.

410 (Gone / no longer exists)
410 (SC_GONE) tells the client the requested document does not exist and there is no updated address. 410 state is different from the 404,410 in the guidance document has been used to remove the case, and 404 for some unknown reason, can not access. This status code is new in HTTP 1.1.

411 (Length Required / required data length)
411 (SC_LENGTH_REQUIRED) that the server can not process the request (assuming the POST request with attachments), unless the client sends a Content-Length header sent to the server that the data size. The state is new in HTTP 1.1.

412 (Precondition Failed / prerequisite error)
412 (SC_PRECONDITION_FAILED) state that the request header information in certain pre-conditions is wrong. The state is new in HTTP 1.1.

413 (Request Entity Too Large / Request entity too large)
413 (SC_REQUEST_ENTITY_TOO_LARGE) tells the client the requested document now want to handle than the server is now larger. If the server that can handle over time, will include a Retry-After response header information. The state is new in HTTP 1.1.

414 (Request URI Too Long / request URI too long)
414 (SC_REQUEST_URI_TOO_LONG) status for the case in the URI is too long. Referred to here "URI" refers to the URL, host, port number after the domain name and content. For example: In the URL - http: / / **y2k-disaster**:8080/we/look/silly/now/ the URI is / we / look / silly / now /. The state is new in HTTP 1.1.

415 (Unsupported Media Type / media format not supported)
415 (SC_UNSUPPORTED_MEDIA_TYPE) attachment means carried by the format of the request type server does not know how to handle. The state is new in HTTP 1.1.

416 (Requested Range Not Satisfiable / request scope can not be met)
416 that includes a server, the client can not meet the Range header requests. The state is new in HTTP 1.1. Curiously, in the servlet 2.1 version of API, HttpServletResponse there is no constant corresponding representative of that state.

Note that the servlet 2.1 specification, the class does not SC_REQUESTED_RANGE_NOT_SATISFIABLE HttpServletResponse this constant, so you can directly use the 416. After the servlet 2.2 version contain this constant.

417 (Expectation Failed / expected failures)
If the server is given a value of 100-continue with the Expect request header information, which means the client is asked if the request can be sent in the following attachment. In this case, the server will use the state (417) tells the browser to the server does not receive the attachment, or with 100 (SC_CONTINUE) status tells the client can continue to send attachments. The state is new in HTTP 1.1.

500 (Internal Server Error / Internal Server Error)
500 (SC_INTERNAL_SERVER_ERROR) is the commonly used "server error" state. The state often caused by a CGI program may (God forbid!) From not working properly or return improperly formatted headers servlet caused.

501 (Not Implemented / not implemented)
501 (SC_NOT_IMPLEMENTED) state tell the client requests the server does not support the required functionality. For example, the client implemented as a server that does not support PUT command.

502 (Bad Gateway / Bad Gateway)
502 (SC_BAD_GATEWAY) is used to act as a proxy or gateway server; the state that receives the remote server, the server receives an error response.

503 (Service Unavailable / service not available)
Status code 503 (SC_SERVICE_UNAVAILABLE) that the server is overloaded due to maintenance or can not respond. For example, if some thread or database connection pool is not free then the servlet will return the header information. Server can provide a Retry-After header telling the client when you can try again.

504 (Gateway Timeout / Gateway timeout)
The state is also used to act as a proxy or gateway server; It noted that the receiving server from a remote server does not receive timely response. The state is new in HTTP 1.1.

505 (HTTP Version Not Supported / Unsupported HTTP version)
505 (SC_HTTP_VERSION_NOT_SUPPORTED) status code is that the server does not support the HTTP version indicated in the request. The state is new in HTTP 1.1.
标签: protocol, conversion, document location, server error, attachments, client error, protocols, constants, 300 399, client requests, error 500, minor changes, expectation, location header
分类: Internet
时间: 2010-12-27


  1. HTTP status codes Remarks

    Complete instructions from the HTTP 1.1 specification RFC 2616, you can ...
  2. Http status codes used Xiangjie

    Complete HTTP 1.1 standard specification from RFC 2616, you can online access. HTTP ...
  3. HTTP status codes and meaning of Daquan

    When the user information service in the defense asked the Internet (IIS) server on the content from time to t ...
  4. Detailed http status code used

    100-199 is used to specify some of the client should be the appropriate action. 200-299 used to indicate the r ...
  5. HTTP 1.1 status codes and their meanings

    The following table shows the common HTTP 1.1 status codes and their corresponding status information and mean ...
  6. SEO, we often encounter HTTP status codes

    As a Seoer, analysis of web log (log) is a very common thing, in the analysis, we will see in the log like thi ...
  7. HTTP status codes and their descriptions

    If you sent a request to the server requests a page on the site (for example, when the user through the web br ...
  8. Enhanced Mail System Status Codes

    Error in setting SAPConnect in the SAP, these status codes are very useful for the problem you need to know th ...
  9. __ Turn http status codes

    HTTP status code (HTTP Status Code) is a web server HTTP response to indicate the status of the 3-digit code. ...
  10. List of HTTP status codes

    English: 100: Continue 101: Switching Protocols 102: Processing 200: OK 201: Created 202: Accepted 203: Non-Au ...
  11. Detailed types of HTTP return status code

    A, HTTP status code If a request is sent to your server requirement that a page on your site (for example, a u ...
  12. Http status code section Detailed

    If a request is sent to your server requirement that a page on your site (for example, a user through a browse ...
  13. http status query http http status code status code explanation queries

    HTTP status code (HTTP Status Code) http status query http http status code status code to explain some common ...
  14. HTTP status code (HTTP Status Code)

    Some common status codes are: 200 - the server successfully returned the page 404 - the requested page does no ...
  15. http protocol status code meaning (change)

    1xx - Information Tips These status codes indicate a provisional response. Client before receiving the convent ...
  16. Common HTTP status description (301,304,200,404)

    301,404,200,304, etc. HTTP status mean? Practical application in the construction site, the easier a lot of li ...
  17. Summary of the browser status code (404,200, etc.)

    These status codes indicate a provisional response. Response to the client prior to receiving regular, should ...
  18. HTTP status code (HTTP Status Code), a common error 404, error 504, etc. Mean

    Some common status codes are: 200 - the server successfully returned the page 404 - the requested page does no ...
  19. AJAX request status return status list of the five state readyState

    ReadyState of the five states for a description or definition, a lot of Ajax Books (English original) and most ...