MCPcopy Create free account
hub / github.com/CSpyridakis/notes / TomcatServer

Class TomcatServer

Java/Maven-http-server/src/main/java/com/example/App.java:36–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36class TomcatServer implements Runnable {
37 private final int port;
38
39 public TomcatServer(int port) {
40 this.port = port;
41 }
42
43 @Override
44 public void run() {
45 try {
46 Tomcat tomcat = new Tomcat();
47 tomcat.setPort(port);
48 tomcat.getConnector().setProperty("address", "0.0.0.0");
49
50 String webappDir = new File("src/main/webapp").getAbsolutePath();
51 tomcat.addWebapp("/", webappDir);
52
53 tomcat.start();
54 System.out.println("Tomcat server started on http://0.0.0.0:" + port);
55 tomcat.getServer().await();
56 } catch (LifecycleException e) {
57 Logger.getLogger(TomcatServer.class.getName()).log(Level.SEVERE, "Error starting Tomcat on port " + port, e);
58 }
59 }
60}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected