public static void main ( final String [ ] args ) throws Exception { // Use jetty to run the servlet. Server server = new Server ( ) ; SocketConnector connector = new SocketConnector ( ) ; connector . setMaxIdleTime ( 0 ) ; connector . setPort ( 8080 ) ; server . addConnector ( connector ) ; WebAppContext context = new WebAppContext ( ) ; context . setContextPath ( "/" ) ; context . addServlet ( HelloWServlet . class . getName ( ) , "/*" ) ; context . addServlet ( ThemeServlet . class . getName ( ) , "/theme/*" ) ; context . setResourceBase ( "." ) ; server . setHandler ( context ) ; server . start ( ) ; }
This main method exists to make it easy to run this servlet without having to create a web . xml file build a war and deploy it .