I am learning java, and trying to run Servlet on local machine and i ran into a problem. No matter what i do it returns 404.
MyServlet.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class MyServlet extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println("Runing servlet");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><body>");
out.println("<h1>Hello Readers</h1>");
out.println("</body></html>");
}
}
web.xml
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<servlet>
<servlet-name>Saturated</servlet-name>
<servlet-class>MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Saturated</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
</web-app>
Folder structure:
/Saturated
/WEB-INF
/classes
MyServlet.class
/lib
servlet-api.jar
web.xml
I have checked catalina logs, /Saturated is started. i checked access log, it responds with 404