What is 404 Not Found Error in Servlets? How to Fix it?

What is 404 Not Found Error in Servlets? How to Fix it?

What is 404 Not Found Errror?

It is status code of the execution of a Servlet or Web application. More clear in the next explanation.

User clicks over a hyperlink, some Servlet is called, executed and the response is sent to the user. Sometimes, the mouse click on the hyperlink calls such an attribute of <ACTION> tag which does not exist on the Web server. That is, the source corresponding to the hyperlink does not exist on the Server. Then what server should do to reply to the user?

Server delivers a message to the client, "404 Not Found". 404 indicates status code of the response. It is a very commonly occurring status code.

404 Not Found indicates:

The source (which can generate the response like a Servlet) requested by the client does not exist on the Server; that is, server is unable to locate the source. Here, client is authorized to access.

Causes of 404 Not Found Error and Fixing it?

  1. The hyperlink (URL) may be broken with some extra spaces not required while it is being typed by the user.
  2. The hyperlink may be a dead hyperlink (which existed earlier but not now).
  3. The source (URL) must have moved to another server temporarily or permanently and server is unable to redirect to the new location.
  4. The extension for an HTML file may be .htm or .html. Should be checked how the server accepts.
    1. For student learning Servlets

    2. Check the spelling of <url-pattern> alias name of Servlet you have typed in the URL (of <ACTION> attrubute of <FORM> tag).
    3. Check you have placed .java file of .class file of the Servlet in the Server.
    4. Check where you have placed .class file and it must be classes folder of Tomcat.
    5. When you correct all, restart the Tomcat and check again.

Know also What is Status code in HTTP Servlets?.

Leave a Reply

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