title: Embedded Jetty application
body: <p>I a newbie in Jetty. I have created an application in which I embed the jetty web container. When I run the the application from eclipse it runs perfectly without any issues. However when I export the project with all the required libraries and run it from command line I cannot access the index.jsp web page like I used to in eclispe. This is the file that run the jetty web container.</p>
  
  <pre><code>public class JettyServer {
  
  // The folder containing all the .jsp files
  private final static String WEB_ROOT = "src/WebContent";
  
  // Instance of the Jetty server
  private final static Server SRV = new Server();
  
  // Context Path
  private final static String CONTEXT_PATH = "/smpp";
  
  // Logging 
  private final static org.slf4j.Logger logger = LoggerFactory.getLogger(JettyServer.class);
  
  /**
   * @param args
   * @throws ConfigurationException 
   */
  public static void main(String[] args) throws ConfigurationException {
      logger.info("Initializing Web Server......");
  
      // Servlet Context
      final ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
  
      // Set the security constraints
      context.setContextPath(CONTEXT_PATH);
      context.setResourceBase(WEB_ROOT);
  
      context.setClassLoader(Thread.currentThread().getContextClassLoader());
  
      context.addServlet(DefaultServlet.class, "/");
      context.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
  
      String [] welcomeFiles = {"index.jsp"};
      context.setWelcomeFiles(welcomeFiles);
      // Set the .jsp servlet handlers
      final ServletHolder jsp = context.addServlet(JspServlet.class, "*.jsp");
      jsp.setInitParameter("classpath", context.getClassPath());
  
      // Session Manager
      SessionHandler sh = new SessionHandler();       
      context.setSessionHandler(sh);
  
      /* Http Request Handlers */
      context.addServlet(HttpRequestProcessor.class, "/HttpHandler");
  
      // Server configuration setup
      // Connector setup
      //  We explicitly use the SocketConnector because the SelectChannelConnector locks files
      Connector connector = new SocketConnector();
      connector.setHost("localhost");
      connector.setPort(Integer.parseInt(System.getProperty("jetty.port", new PropertiesConfiguration("smpp-config.properties").getString("http_port").trim())));
      connector.setMaxIdleTime(60000);
  
      JettyServer.SRV.setConnectors(new Connector[] { connector });
      JettyServer.SRV.setHandler(context);
      JettyServer.SRV.setAttribute("org.mortbay.jetty.Request.maxFormContentSize", 0);
      JettyServer.SRV.setGracefulShutdown(5000);
      JettyServer.SRV.setStopAtShutdown(true);
  
      logger.info("Starting Jetty Web Container....");
      try{
          JettyServer.SRV.start();
      } 
      catch(Exception ex){
          logger.error("Jetty Web Container failed to start [CAUSE : " + ex.getMessage() + "]");
          return;
      }
  
  
      logger.info("Jetty Web Container running....");
      while(true){
          try{
              JettyServer.SRV.join();
          }
          catch(InterruptedException iex){
              logger.error("Jetty Web Container interrupted [CAUSE : " + iex.getMessage() + "]");
          }
      }       
  }   
  }
  </code></pre>
  
  <p>code formatted properly</p>