Retrieving response status code

Top  Previous  Next

The status code of an HTTP response is used to indicate the success or failure of the HTTP request.

 

Example

 

// get response

HttpResponse response = http.getResponse(request);

 

// get response code

int responseCode = response.getResponseCode();

 

 

HTTP response codes

 

Code

Description

200

OK. The request was fulfilled.

201

Created. Following a POST command, this indicates success, but the textual part of the response line indicates the URI by which the newly created document should be known.

202

Accepted. The request has been accepted for processing, but the processing has not been completed. The request may or may not eventually be acted upon, as it may be disallowed when processing actually takes place. there is no facility for status returns from asynchronous operations such as this.

203

Partial Information. When received in the response to a GET command, this indicates that the returned meta information is not a definitive set of the object from a server with a copy of the object, but is from a private overlaid web. This may include annotation information about the object, for example.

204

No Response. Server has received the request but there is no information to send back, and the client should stay in the same document view. This is mainly to allow input for scripts without changing the document at the same time.

301

Moved. The data requested has been assigned a new URI, the change is permanent. (N.B. this is an optimization, which must, pragmatically, be included in this definition.

302

Found. The data requested actually resides under a different URL, however, the redirection may be altered on occasion.

304

Not Modified. If the client has done a conditional GET and access is allowed, but the document has not been modified since the date and time specified in If-Modified-Since field, the server responds with a 304 status code and does not send the document body to the client.

400

Bad Request. The request had bad syntax or was inherently impossible to be satisfied.

401

Unauthorized. The parameter to this message gives a specification of authorization schemes which are acceptable. The client should retry the request with a suitable Authorization header.

402

Payment Required. The parameter to this message gives a specification of charging schemes acceptable. The client may retry the request with a suitable ChargeTo header.

403

Forbidden. The request is for something forbidden. Authorization will not help.

404

Not Found. The server has not found anything matching the URI given

500

Internal Error. The server encountered an unexpected condition which prevented it from fulfilling the request.

501

Not Implemented. The server does not support the facility required.





Home | Company | Products | Solutions | Purchase | Support | Services | Blog

© 2021 JSCAPE LLC