A minimal Java web application intended for junior developers learning the basics of Java web apps, servlets, and JSPs. The app runs an embedded Tomcat server and serves static resources from src/main/webapp.
- Java 25 (as configured in
pom.xml) - Maven 3.9+
src/main/java— Java source code (including the embedded Tomcat bootstrap inuk.ac.ucl.main.Main)src/main/webapp— Static web resources and JSPstarget— Build output (created by Maven)war-file— Packaged WAR output (created by Maven)
Build the project and produce a WAR file:
mvn clean packageThis writes the WAR to war-file/.
First compile the project, then run the main class via Maven:
mvn clean compile exec:execBy default the server starts on port 8080. Open:
http://localhost:8080
You can configure the server using system properties or environment variables:
SERVER_PORT— Port to bind (default:8080)WEBAPP_DIR— Web resources directory (default:src/main/webapp/)CLASSES_DIR— Compiled classes directory (default:target/classes)
Example (using environment variables):
SERVER_PORT=9090 mvn clean compile exec:exec- The entry point is
uk.ac.ucl.main.Maininsrc/main/java/uk/ac/ucl/main/Main.java. - Packaging as a WAR is useful if you want to deploy to an external Tomcat later.