A small Java web project with one Servlet, one HTML form, and a Maven WAR build. Use JDK 21, Maven 3.9+ in the Maven 3 series, and Tomcat 10.1. JSP and database setup come later in the todo tutorial.
Extract the ZIP. Open the hello-servlet folder containing pom.xml in VS Code. Open its terminal and run:
java -version
javac -version
mvn -version
mvn clean package
Wait for BUILD SUCCESS. Find target/hello-servlet.war. Building does not start Tomcat or deploy the WAR.
C:\Program Files\Apache Software Foundation\Tomcat 10.1\webapps; use your actual installation.Click the Hello World link. At /hello-servlet/hello, expect Hello, World!. Enter Priya in the form; expect Hello, Priya!. This response is generated by HelloServlet.doGet, rather than the HTML file.
pom.xml: Java target, Servlet API dependency and WAR packaging. Tomcat supplies the Servlet API at runtime.src/main/java/com/example/web/HelloServlet.java: maps /hello, reads name, returns plain text.src/main/webapp/index.html: static welcome page and GET form.src/main/webapp/WEB-INF/web.xml: declares the welcome file.For 404, confirm hello-servlet.war is in the running instance's webapps folder, wait for deployment and inspect its logs. For an occupied port, use the existing server. In Windows CMD use copy, %CATALINA_HOME% and .bat scripts; Linux/macOS cp and .sh commands belong in Bash/Zsh.
Full installation, deployment and troubleshooting instructions
After changing code, rebuild the WAR and redeploy it. When this project works, continue with the larger todo-servlet-jsp project.