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?
- The hyperlink (URL) may be broken with some extra spaces not required while it is being typed by the user.
- The hyperlink may be a dead hyperlink (which existed earlier but not now).
- The source (URL) must have moved to another server temporarily or permanently and server is unable to redirect to the new location.
- The extension for an HTML file may be .htm or .html. Should be checked how the server accepts.
- For student learning Servlets
- Check the spelling of <url-pattern> alias name of Servlet you have typed in the URL (of <ACTION> attrubute of <FORM> tag).
- Check you have placed .java file of .class file of the Servlet in the Server.
- Check where you have placed .class file and it must be classes folder of Tomcat.
- When you correct all, restart the Tomcat and check again.
Know also What is Status code in HTTP Servlets?.