title: Serve static content with Jersey 2.22.2
body: <p>I have a REST Api that I developed using Jersey, everything works fine when it comes to Json in / out. and that I'm consuming by Ajax.</p>
  
  <p>However, due to Cross-Domain limitations on the browsers, I'd like to package the static website (JS / Images / HTMLs / CSS) on my WAR</p>
  
  <p>This is how my web.xml looks like : </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://xmlns.jcp.org/xml/ns/javaee"
      xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
      id="RESTApi" 
      version="3.1"&gt;
  
      &lt;display-name&gt;RESTApi&lt;/display-name&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;Test -&gt; Jersey RESTful API&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;jersey.config.server.provider.packages&lt;/param-name&gt;
              &lt;param-value&gt;com.bc.api&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;Test -&gt; Jersey RESTful API&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>and my static content on the project structure : </p>
  
  <p><a href="https://i.stack.imgur.com/Gmlus.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gmlus.png" alt="enter image description here"></a></p>
  
  <p>Now when I try to access <code>http://localhost:8080/static/index.html</code> it's processed as a REST call.</p>
  
  <p>How can I make the static directory packages and accessed through the API?</p>