Created
March 5, 2015 06:40
-
-
Save gregw/423e6c26d19b42f62ea0 to your computer and use it in GitHub Desktop.
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 OneServletContext | |
{ | |
public static void main( String[] args ) throws Exception | |
{ | |
Server server = new Server(8080); | |
ServletContextHandler context = new ServletContextHandler( | |
ServletContextHandler.SESSIONS); | |
((ErrorPageErrorHandler)context.getErrorHandler()).addErrorPage(404,"/some/uri/for/404"); | |
((ErrorPageErrorHandler)context.getErrorHandler()).addErrorPage(500,"/some/uri/for/500"); | |
((ErrorPageErrorHandler)context.getErrorHandler()).addErrorPage(NullPointerException.class,"/null/pointer/uri"); | |
context.setContextPath("/"); | |
context.setResourceBase(System.getProperty("java.io.tmpdir")); | |
server.setHandler(context); | |
// Add dump servlet | |
context.addServlet(DumpServlet.class, "/dump/*"); | |
// Add default servlet | |
context.addServlet(DefaultServlet.class, "/"); | |
server.start(); | |
server.join(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment