title: Servlet Mappings Jetty 8
body: <p>I have a webapp that works with Tomcat 8 and Jetty 8. Recently, we have introduced servlet-mappings</p>
  
  <pre><code>    &lt;servlet&gt;
          &lt;servlet-name&gt;page&lt;/servlet-name&gt;
          &lt;jsp-file&gt;/Dashboard.html&lt;/jsp-file&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
     &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;page&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/editjob&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>When you put an url with "<a href="http://localhost:8080/app/editjob" rel="nofollow">http://localhost:8080/app/editjob</a>", in tomcat is redirected to "<a href="http://localhost:8080/app/Dashboard.html" rel="nofollow">http://localhost:8080/app/Dashboard.html</a>". But when we deploy it using embed Jetty, a 404 Not Found  it is being returned. It seems that the servlet-mapping is not working. </p>
  
  <pre><code>HTTP ERROR 404
  Problem accessing /app/page. Reason:
  Not Found
  Powered by Jetty://
  </code></pre>
  
  <p>I can enter in the app by using directly 
  <a href="http://localhost:8080/app/Dashboard.html" rel="nofollow">http://localhost:8080/app/Dashboard.html</a>. Without mappings, we have no problem with jetty
  This is the code for embedding Jetty:</p>
  
  <pre><code>final Server server = new Server();
  SocketConnector connector = new SocketConnector();
  connector.setMaxIdleTime(-1);
  connector.setSoLingerTime(-1);
  connector.setPort(8080);
  server.setConnectors(new Connector[]{connector});
  final WebAppContext context = new WebAppContext();
  context.setServer(server);
  context.setContextPath("app");
  context.setWar(location.toExternalForm());
  server.setHandler(context);
  context.start();  
  server.join();
  </code></pre>
  
  <p>This is the web.xml with the mappings.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  &lt;display-name&gt;app&lt;/display-name&gt;
  &lt;servlet&gt;
      &lt;servlet-name&gt;ServletAdaptor&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt;
  
      &lt;init-param&gt;
          &lt;param-name&gt;com.sun.jersey.api.json.POJOMappingFeature&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;ServletAdaptor&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/webresources/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
       &lt;servlet&gt;
          &lt;servlet-name&gt;login&lt;/servlet-name&gt;
          &lt;jsp-file&gt;/Login.html&lt;/jsp-file&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;page&lt;/servlet-name&gt;
          &lt;jsp-file&gt;/Dashboard.html&lt;/jsp-file&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  &lt;session-config&gt;
      &lt;session-timeout&gt;
          30
      &lt;/session-timeout&gt;
  &lt;/session-config&gt;
  &lt;servlet&gt;
      &lt;servlet-name&gt;context&lt;/servlet-name&gt;
      &lt;servlet-class&gt;
          org.springframework.web.context.ContextLoaderServlet
      &lt;/servlet-class&gt;
  &lt;/servlet&gt; 
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/beans.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;filter&gt;
      &lt;filter-name&gt;CORS&lt;/filter-name&gt;
      &lt;filter-class&gt;com.thetransactioncompany.cors.CORSFilter&lt;/filter-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;cors.allowGenericHttpRequests&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;cors.allowOrigin&lt;/param-name&gt;
          &lt;param-value&gt;*&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;cors.allowSubdomains&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;cors.supportedMethods&lt;/param-name&gt;
          &lt;param-value&gt;GET, POST, HEAD, PUT, DELETE, OPTIONS&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;cors.supportedHeaders&lt;/param-name&gt;
          &lt;param-value&gt;Origin, Content-Type, X-Requested-With, Access-Control-Allow-Origin&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;cors.supportsCredentials&lt;/param-name&gt;
          &lt;param-value&gt;false&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;cors.maxAge&lt;/param-name&gt;
          &lt;param-value&gt;-1&lt;/param-value&gt;
      &lt;/init-param&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;CORS&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;login&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/login&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;page&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/home&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;page&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/jobs&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
     &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;Index.html&lt;/welcome-file&gt;
  
  &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>I have tried to define the servlet-mappings when i start the server, but did not work.
  This mappings are working perfectly with Tomcat, but Jetty...I dont know which could be the problem.</p>
  
  <p>Thanks in advance.</p>