Open In App

JSP – HTTP Status Codes

Last Updated : 17 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

When the Client makes any requests to the server, the Status Codes are issued by the server as a response to the client’s request. So, in an application, we have the client and the server architecture. The server is the part that holds the particular web service or an API. The client is the actor who sends that HTTP request to the server. So, whenever the client sends the HTTP request, the server processes that request and it sends back the HTTP response.

The HTTP request contains the HTTP Status Code, body, as well as the headers. Out of these HTTP Status Code is a three-digit number. This three-digit number has a meaning associated with it and all the clients who invoke the HTTP request or receive the HTTP response are very well aware of the meaning of the HTTP Status Code. So, by reading the Status Code, they will understand what the response to that request is, and depending on whether it is a success or it is an error response, they can take the next steps for processing.

In this article, we are going to explore HTTP Status Codes, the different categories of these Status Codes, commonly used Codes, and finally, we will see the HTTP Status Code received in response by sending a few requests via Postman.

HTTP Status Code

Note: HTTP Code are universally recognized by all the HTTP applications. It is irrespective of the technology.

HTTP Status Code Categories

The status code has been divided into total five groups. Which means the number of status codes we had has been divided into five groups. Within each group, there are different values that will have different meanings, which we will explore here. Five group is 1xx, 2xx, 3xx, 4xx and 5xx. Here x means that any value can come here. We also use x in ethical hacking that any matter can go there.

  • 1xx (Informational Codes): This category is used whenever the request is received by the server and is continuing the process.
  • 2xx (Success Codes): This category is used whenever the request is processed successfully by the server.
  • 3xx (Redirection Codes): This category is used whenever you want to redirect the client to some different URL.
  • 4xx (Client Error Codes): This category defines the error codes which are caused due to the issue in the input request which is sent by the client, it could be issue with the payload or authorization header.
  • 5xx (Server Error Codes): This category defines the error codes because of the issue that has happened on the server side while processing that request.

Commonly Used HTTP Status Codes

Here are some commonly used HTTP Status Codes in all of these categories:

2xx (Success):

  • 200 (OK): It is frequently used in GET request.
  • 201 (Created): It indicates that the resource is successfully created by the Server
  • 202 (Accepted):
  • 206 (Partial Content): It indicates that the request is processed successfully but it is kind of a partial success not entirely that request is successful.

3xx (Redirection):

  • 301 (Moved Permanently): It indicates that this particular api has been moved to some different URI.

4xx (Client Error):

  • 400 (Bad Request): It indicates that the request itself has some syntax error or it is missing mandatory parameters.
  • 401 (Unauthorized): It indicates that the client is not able to successfully authenticate himself.
  • 403 (Forbidden): It is also on the same lines of 401 but the only difference is the authentication is successful. The resource also exists on the server side but the user does not have access for that particular resource.
  • 404 (Not Found): In case the resource is not found or even if you enter any invalid URL.
  • 405 (Method Not Allowed): The particular API supports only GET method and if you are trying to use post or delete in that case you might get these errors.

5xx (Server Error):

  • 500(Internal Server Error): It indicates that there were some issues with processing of that request.
  • 501(Not Implemented): It indicates that the URI that we are trying to implement or the method that we are trying to implement itself is not implemented on the server side.
  • 503(Service Unavailable): It indicates that the request could not process either because the server was not available, or it was down due to some reasons.
  • 504(Gateway Timeout): This error occurs for e.g. if the server is acting as a proxy, then it receives the timeout from the upstream servers.

Output of HTTP Status Codes in Postman

Below are few examples of HTTP Status Code in a few of the requests that you might encounter in Postman.

200 OK:

Output for 200 OK

201 Created:

Output for 201 Created

400 Bad Request:

Output for 400 Bad Request

404 Not Found:

Output for 404 Not Found

406 Not Acceptable:

Output for 406 Not Acceptable

500 Internal Server Error:

Output for 500 Internal Server Error



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads