-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServletMain.java
More file actions
29 lines (24 loc) · 976 Bytes
/
Copy pathServletMain.java
File metadata and controls
29 lines (24 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.example.servlet;
import org.eclipse.jetty.ee10.servlet.ServletContextHandler;
import org.eclipse.jetty.ee10.servlet.ServletHolder;
import org.eclipse.jetty.server.Server;
import io.github.ghosthack.turismo.servlet.Servlet;
/**
* Runs {@link AppRoutes} in embedded Jetty. The same servlet setup works in
* any Jakarta EE 10 container through web.xml (see the README).
*
* <p>Run with {@code mvn compile exec:java -Dexec.mainClass=com.example.servlet.ServletMain}
*/
public class ServletMain {
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
ServletContextHandler ctx = new ServletContextHandler();
ctx.setContextPath("/");
ServletHolder holder = new ServletHolder(new Servlet());
holder.setInitParameter("routes", AppRoutes.class.getName());
ctx.addServlet(holder, "/*");
server.setHandler(ctx);
server.start();
server.join();
}
}