What is Status code in HTTP Servlets?

What is Status code in HTTP Servlets?

1. What is Status code in HTTP?
2. Why status codes?

This gives introduction to status code.

Here, I talk in my own style for a better understanding for a very beginner. Suppose, I develop a software product like School product and supplied to a School. Well, the software is working nice to the satisfaction of the client. One day, a call is received by my supporting team about malfunction of the product. The support team member asked the client to read of the error message or explain about the error. The School Teacher is unable to explain properly (or team member is unable to extract the information he required) and thereby the support team member, finally, is unable to rectify the problem. It leads to customer dissatisfaction.

Then what best I can do as an Architect of the product. For every possible problem, the client may get with my School product, I give a number (followed by some extra notes). Now the School Teacher reads the number to the support team. By listening the number, the team understands the problem and fix it over phone itself.

This number, I designed, is known as "status code". As the name implies, it gives the status of the request of the client by the server. Do not think status code is meant for only errors always. See, it is after all the status of the request, sometimes even the request honoured by Web server without any problem and Okayed, it can also be given a status code. That is, even for accepted or not accepted requests, the requests processed successfully or not processed, sometimes the client is forbidden to access the information, all these are given status codes in HTTP protocol.

3. Who can use these Status codes?
4. Who developed these Status codes?

W3C (World Wide Consortium) developed these status codes along with the development of HTTP protocol (originally developed by Web’s inventor, Tim Berners-Lee in 1992 while developing FTP). A list of status codes is maintained by The Internet Assigned Numbers Authority (IANA). It is treated as the official registry of HTTP status codes. Because these are not proprietary, any Web technology using HTTP protocol can make use of them like ASP, Servlets/JSP, PHP etc.

5. Can you explain one Status code example clearly?
6. What is Status code 404 carries the message to client by Web server?
7. How to fix 404 error message?

404 is a very commonly occurring status code number even to a Programmer while the software is being integrated. 404 means, what the client requested is not available with the server (resource not found). That is, client has requested a Servlet on the server by quoting some alias name and clicking over Submit button, the server did not find a Servlet matching to that in the URL.

The possible mistakes, the Programmer can commit are:

  1. Alias name written in the URL (in <form action="xxx"> may not be the same (for misspelling) as given in web.xml file.
  2. The Servlet may not be placed in the correct directory like "classes" folder.
  3. The source file of .java extension must have been placed in "classes" folder instead of its .class file.

If the Programmer can fix anyone of the above mistakes, most probably, he may come out of the 404 error.


2 more Postings exist on Status codes for your further reading.

1. Classification of Status Codes in HTTP
2. List of Status codes – Commonly occurring

View All Servlets

Leave a Reply

Your email address will not be published. Required fields are marked *