title: How can I serve static content with Glassfish embedded?
body: <p>I'm trying to setup Glassfish embedded with a WAR project that implements a REST API and then some static Javascript content that calls it. I got the WAR to deploy and the REST API is available with a context root of "/Users".</p>
  
  <p>How can I use Glassfish to serve static content with a context root of "/". So for example, if the user requests <a href="http://myserver.com/Users/some-REST-call" rel="nofollow">http://myserver.com/Users/some-REST-call</a> it routes to the WAR application and <a href="http://myserver.com/somefile.js" rel="nofollow">http://myserver.com/somefile.js</a> serves a static file from some directory?</p>
  
  <p>Here's my Main class file so far:</p>
  
  <pre><code>public class Main{
      public static void main(String[] args) throws Exception {
          String port = System.getenv("PORT");
          port = port != null ? port : "8080";
          GlassFishProperties gfProps = new GlassFishProperties();
          gfProps.setPort("http-listener", Integer.parseInt(port));
  
          GlassFish glassfish = GlassFishRuntime.bootstrap().newGlassFish(gfProps);
          glassfish.start();
  
          Deployer deployer = glassfish.getDeployer();
  
          deployer.deploy(new File("target/Users-Rest.war"));
      }
  }
  </code></pre>
  
  <p>P.S. I'm aware that ideally you'd use Apache to serve the static content, however, I'm using Glassfish embedded to try to deploy to Heroku. Thanks a ton for your help!</p>