Continuous Error 404 in servlet operation [How to Solve]

When writing the project, the servlet has been unable to work normally. After consulting the data for many times, we found the following possibilities.

First, automatic editing is not turned on

In the top project option, check build automatically from the drop-down list

Second: the version of the top header in web.xml is too low

The author uses @ webservlet (urlpatterns =/xxservlet) mode, which does not need to configure servlet file in web.xml, but only version 3.0 or above supports this mode. Therefore, in web.xml, there must be version = 3.1.

You can directly copy the following code to use.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
  <display-name>Project Name</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

Third: Tomcat configuration problems

Remove Tomcat from the server and install Tomcat again according to the process.

1. Delete Tomcat

2. Select preference in the top window option. In the pop-up box, select server — runtime environment — and select the original Tomcat — remove

3. Then click Add to configure the Tomcat you downloaded.

I hope eclipse will work properly.

Read More: