Jsp HTTP status code and jsphttp status code

Source: Internet
Author: User

Jsp HTTP status code and jsphttp status code

The formats of HTTP requests and HTTP responses are similar and both have the following structure:

  • Start with status line + CRLF (carriage return)
  • Zero-line or multi-line header module + CRLF
  • A blank line, such as CRLF
  • Optional message bodies such as files, query data, and query output

For example, a server response header looks like the following:

HTTP/1.1 200 OKContent-Type: text/htmlHeader2: ......HeaderN: ...  (Blank Line)<!doctype ...>

The status line contains the HTTP version, a status code, and a short message corresponding to the status code.

The following table lists the HTTP status codes and associated messages that may be returned from the server:

Status Code Message Description
100 Continue Only a part of the request is received by the server, but as long as the request is not rejected by the server, the client will continue the request.
101 Switching Protocols Server switch protocol
200 OK Request confirmed
201 Created The request is complete, and new resources are created
202 Accepted Request accepted, but not processed
203 Non-authoritative Information  
204 No Content  
205 Reset Content  
206 Partial Content  
300 Multiple Choices A hyperlink table. You can select and access a hyperlink. A maximum of five hyperlinks are supported.
301 Moved Permanently The requested page has been moved to the new URL.
302 Found The requested page is temporarily moved to the new URL.
303 See Other The requested page can be found under a different URL
304 Not Modified  
305 Use Proxy  
306 Unused This status code is no longer used, but it is retained
307 Temporary Redirect The requested page is temporarily moved to the new URL.
400 Bad Request The server cannot identify the request
401 Unauthorized The user name and password are required for the requested page.
402 Payment Required This status code is currently unavailable
403 Forbidden Prohibit access to the requested page
404 Not Found The server cannot find the requested page
405 Method Not Allowed The method specified in the request is not allowed.
406 Not Acceptable The server can only create a response that the client cannot accept.
407 Proxy Authentication Required A proxy server must be authenticated before a request is sent to the service.
408 Request Timeout The connection is disconnected because the request time exceeds the waiting time of the server.
409 Conflict Conflicting requests
410 Gone The requested page is no longer available
411 Length Required "Content-Length" is not defined, and the server rejects the request
412 Precondition Failed The server evaluates the request's prerequisites to false.
413 Request Entity Too Large The server rejects the request because the requested entity is too large.
414 Request-url Too Long The server rejects the request because the URL is too long. A large amount of query information included in converting a "POST" request to a "GET" Request
415 Unsupported Media Type The server rejects the request because the media type is not supported.
417 Expectation Failed  
500 Internal Server Error The request is incomplete, and the server encountered unexpected conditions.
501 Not Implemented The request is incomplete and the server does not provide the required functions.
502 Bad Gateway The request is incomplete and the server receives an invalid response from the upstream server.
503 Service Unavailable The request is incomplete. The server is temporarily restarted or shut down.
504 Gateway Timeout Gateway timeout
505 HTTP Version Not Supported The server does not support the specified HTTP Version.
  How to set the HTTP status code

The following table lists the methods used to set status codes in the HttpServletResponse class:

S. N. Method&Description
1 Public void setStatus (int statusCode)This method can be used to set any status code. If your response contains a special status code and a document, make sure to call the setStatus method before using PrintWriter to return any content
2 Public void sendRedirect (String url)This method generates a 302 response and generatesLocationHeader to tell the URL a new document
3 Public void sendError (int code, String message)This method automatically inserts a status code (usually 404) and a short message into the HTML document and sends it back to the client.
  HTTP status code example

The following example will send the 407 error code to the browser, and then the browser will tell you "Need authentication !!! ".

<Html> 

You can also try other status codes to see if any unexpected results are returned.

 

Address: http://www.manongjc.com/jsp/jsp_http_status.html

JSP-related materials:

  • Jsp tutorial
  • Jsp Introduction
  • Jsp development environment construction
  • Jsp Structure
  • Jsp Lifecycle
  • Jsp syntax
  • Jsp commands
  • Jsp Action Element
  • Jsp implicit object
  • Jsp client request
  • Jsp server response
  • Jsp HTTP status code
  • Jsp Form Processing
  • JSP Filter
  • Jsp Cookies Processing
  • Jsp Session
  • Jsp File Upload
  • Jsp Date Processing
  • JSP page redirection
  • Jsp clicks statistics
  • Automatic jsp refresh
  • Jsp send mail
  • Jsp standard tag Library (JSTL)
  • Jsp connection to database
  • Jsp xml Data Processing
  • Jsp JavaBean
  • Jsp custom tag
  • Jsp Expression Language
  • Jsp Exception Handling
  • Jsp debugging
  • Jsp Internationalization

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.