Following is a list of all the available HTTP 1.1 status codes, along with their associated message and interpretation. You should be cautious in using the status codes that are available only in HTTP 1.1, since many browsers still only support HTTP 1.0. If you do use status codes specific to HTTP 1.1, in most cases you want to either explicitly check the HTTP version of the request (via the getProtocol method of the HttpServletRequest) or reserve it for situations when no HTTP 1.0 status code would be particularly meaningful to the client anyhow.


Status CodeAssociated MessageMeaning
100ContinueContinue with partial request. (New in HTTP 1.1)
101Switching ProtocolsServer will comply with Upgrade header and
change to different protocol. (New in HTTP 1.1)
200OKEverything's fine; document follows for GET and
POST
 requests. This is the default for servlets; if you
don't use setStatus, you'll get this.
201CreatedServer created a document; the Location header
indicates its URL.
202AcceptedRequest is being acted upon, but processing is not
completed.
203Non-Authoritative InformationDocument is being returned normally, but some of the
response headers might be incorrect since a document copy is being
used. (New in HTTP 1.1)
204No ContentNo new document; browser should continue to display previous
document. This is a useful if the user periodically reloads a page
and you can determine that the previous page is already up to date.
However, this does not work for pages that are automatically
reloaded via the Refresh response header or the equivalent <="" <="" code="" http-equiv="Refresh" meta=""> header, since returning this status
code stops future reloading. JavaScript-based automatic reloading
could still work in such a case, though.
205Reset ContentNo new document, but browser should reset document view.
Used to force browser to clear CGI form fields. (New in HTTP 1.1)
206Partial ContentClient sent a partial request with a Range
header, and server has fulfilled it. (New in HTTP 1.1)
300Multiple ChoicesDocument requested can be found several places; they'll be
listed in the returned document. If server has a preferred choice,
it should be listed in the Location response header.
301Moved PermanentlyRequested document is elsewhere, and the URL for it is given
in the Location response header. Browsers should
automatically follow the link to the new URL.
302FoundSimilar to 301, except that the new URL should be
interpreted as a temporary replacement, not a permanent one. Note:
the message was "Moved Temporarily" in HTTP 1.0, and the constant in
HttpServletResponse
 is SC_MOVED_TEMPORARILY,
not SC_FOUND.
Very useful header, since browsers
automatically follow the link to the new URL. This status code is
so useful that there is a special method for it,sendRedirect.
Using response. sendRedirect(url) has a couple of
advantages over doing response. setStatus
(response.SC_MOVED_TEMPORARILY)
 and response.
setHeader("Location", url)
. First, it is easier. Second, with sendRedirect,
the servlet automatically builds a page containing the link (to show
to older browsers that don't automatically follow redirects).
Finally, 
sendRedirect
can handle relative URLs, automatically translating them to
absolute ones.
 
Note that this status code is sometimes used interchangeably with
301. For example, if you erroneously ask for
http://host/~user
 
(missing the trailing slash), some servers will send 301 and others
will send 302.

Technically, browsers are only supposed to automatically follow the redirection if the original request was GET.
See the 307 header for details.
303See OtherLike 301/302, except that if the original request wasPOST,
the redirected document (given in the Locationheader)
should be retrieved via GET. (New in HTTP 1.1)
304Not ModifiedClient has a cached document and performed a conditional
request (usually by supplying an If-Modified-Since
header indicating that it only wants documents newer than a
specified date). Server wants to tell client that the old, cached
document should still be used.
305Use ProxyRequested document should be retrieved via proxy listed in Location
header. (New in HTTP 1.1)
307Temporary RedirectThis is identical to 302 ("Found" or "Temporarily Moved").
It was added to HTTP 1.1 since many browsers erroneously followed
the redirection on a 302 response even if the original message was a
POST
 , even though it really ought to have followed the
redirection of a POST request only on a 303 response.
This response is intended to be unambigously clear: follow
redirected GET and POST requests in
the case of 303 responses, only follow the redirection for GET

requests in the case of 307 responses. Note: for some reason there
is no constant in HttpServletResponse corresponding to
this status code. (New in HTTP 1.1)
400Bad RequestBad syntax in the request.
401UnauthorizedClient tried to access password-protected page without
proper authorization. Response should include aWWW-Authenticate
header that the browser would use to pop up a username/password
dialog box, which then comes back via theAuthorization
header.
403ForbiddenResource is not available, regardless of authorization.
Often the result of bad file or directory permissions on the server.
404Not FoundNo resource could be found at that address. This is the
standard "no such page" response. 
This is such a common and
useful response that there is a special method for it in HttpServletResponse:
sendError(message). The advantage of sendError
over setStatus is that, with sendError,
the server automatically generates an error page showing the error
message.
405Method Not AllowedThe request method (GETPOSTHEAD,
DELETE
 PUTTRACE, etc.) was
not allowed for this particular resource. (New in HTTP 1.1)
406Not AcceptableResource indicated generates a MIME type incompatible with
that specified by the client via its Accept header.
(New in HTTP 1.1)
407Proxy Authentication RequiredSimilar to 401, but proxy server must return a Proxy-Authenticate
header. (New in HTTP 1.1)
408Request TimeoutThe client took too long to send the request. (New in HTTP
1.1)
409ConflictUsually associated with PUT requests; used for
situations such as trying to upload an incorrect version of a file.
(New in HTTP 1.1)
410GoneDocument is gone; no forwarding address known. Differs from
404 in that the document is is known to be permanently gone in this
case, not just unavailable for unknown reasons as with 404. (New in
HTTP 1.1)
411Length RequiredServer cannot process request unless client sends a Content-Length
header. (New in HTTP 1.1)
412Precondition FailedSome precondition specified in the request headers was
false. (New in HTTP 1.1)
413Request Entity Too LargeThe requested document is bigger than the server wants to
handle now. If the server thinks it can handle it later, it should
include a Retry-After header. (New in HTTP 1.1)
414Request URI Too LongThe URI is too long. (New in HTTP 1.1)
415Unsupported Media TypeRequest is in an unknown format. (New in HTTP 1.1)
416Requested Range Not SatisfiableClient included an unsatisfiable Range header
in request. (New in HTTP 1.1)
417Expectation FailedValue in the Expect request header could not be
met. (New in HTTP 1.1)
500Internal Server ErrorGeneric "server is confused" message. It is often the result
of CGI programs or (heaven forbid!) servlets that crash or return
improperly formatted headers.
501Not ImplementedServer doesn't support functionality to fulfill request.
Used, for example, when client issues command like PUT
that server doesn't support.
502Bad GatewayUsed by servers that act as proxies or gateways; indicates
that initial server got a bad response from the remote server.
503Service UnavailableServer cannot respond due to maintenance or overloading. For
example, a servlet might return this header if some thread or
database connection pool is currently full. Server can supply a Retry-After
header.
504Gateway TimeoutUsed by servers that act as proxies or gateways; indicates
that initial server didn't get a response from the remote server in
time. (New in HTTP 1.1)
505HTTP Version Not SupportedServer doesn't support version of HTTP indicated in request
line. (New in HTTP 1.1)

0 comments:

Post a Comment

 
Top