Created
November 13, 2014 17:32
-
-
Save derekbassett/cd0dbc261a49a451657a to your computer and use it in GitHub Desktop.
Simple instructions on how to add an Async Servlet to an Embedded Tomcat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
private static final int PORT = 8085; | |
public static void main(String args[]){ | |
Tomcat server = new Tomcat(); | |
server.setPort(PORT); | |
Context ctx = server.addContext("/ctx0", new File(".").getAbsolutePath()); | |
Wrapper wrapper = Tomcat.addServlet(ctx, "MyAsyncServlet", new MyAsyncServlet()); | |
// Have to set Async supported on this servlet since we are not using annotations. | |
wrapper.setAsyncSupported(true); | |
ctx.addServletMapping("/*", "MyAsyncServlet"); | |
server.start(); | |
// Wait for some condition and then stop | |
server.stop(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are many examples on the web on how to create a Tomcat Servlet using an embedded Tomcat but none on how to create an async servlet