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.Use macOS Terminal/Zsh, a matching JDK 21, and an extracted Tomcat 10.1. Replace the Tomcat folder below with your actual extracted version. Run from the hello-servlet folder, after stopping your own foreground Tomcat:
export JAVA_HOME="$(/usr/libexec/java_home -v 21)"
export CATALINA_HOME="$HOME/tools/apache-tomcat-10.1.61"
mvn -version
mvn clean package
cp target/hello-servlet.war "$CATALINA_HOME/webapps/hello-servlet.war"
bash "$CATALINA_HOME/bin/catalina.sh" run
Copy/start only after BUILD SUCCESS. If another Tomcat already runs, use that instance instead of starting a second copy. For persistent Path settings, Apple Silicon/Intel downloads and common Mac errors, open the complete MacBook setup guide.
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.