I'm a beginner in Servlets and Tomcat, and I'm making a simple Hello World program
I have read lots of posts about this and I am still clueless as to why my approach to Tomcat doesn't work. Here's the full directory / project of mine:
WebTest:
package classes;
import java.io.IOException;
import java.io.PrintWriter;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@WebServlet(name = "WebTest", urlPatterns = {"/fing"})
public class WebTest extends HttpServlet  {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        try {
            PrintWriter out = response.getWriter();
            out.println("<html>");
            out.println("<head>");
            out.println("<title> Home Page </title>");
            out.println("</head>");
            out.println("<body>");
            out.println("<h1> Hello there </h1>");
            out.println("<html>");
            out.println("</html>");
    
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
index.html:
<!DOCTYPE html>
<html lang="en">
    <head>
        <title> Home Page </title>
    </head>
    <body>
        <h1>Hello world</h1>
        <form  action= "./fing" method = "post" >
            <label>Enter name:</label> <input type="text" name = "user">
            <input type = "submit" value="Click Here">
        </form>
    </body>
</html>
web.xml:
<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
  <display-name>Archetype Created Web Application</display-name>
  
</web-app>
Project Set up:
Note: I'm using Tomcat 10.0.8 and jakarta.servlet 6.0.0
I tried to change the web.xml file instead of inserting the Annotation but the issue still persists. I expect the web to have a different text on it


 
    