Код: Выделить всё
public class TestStarter {
public static void main(String[] args) throws LifecycleException {
Tomcat tomcat = new Tomcat();
tomcat.setPort(8080);
tomcat.getConnector();
String contextPath = "";
String docBase = new File(".").getAbsolutePath();
Context context = tomcat.addContext(contextPath, docBase);
String servletName = "HelloServlet";
tomcat.addServlet(contextPath, servletName, new HelloServlet());
context.addServletMappingDecoded("/test", servletName);
tomcat.start();
tomcat.getServer().await();
}
}
Подробнее здесь: https://stackoverflow.com/questions/788 ... ool-in-tom