users@grizzly.java.net

How to server static html from within a jar

From: Macbeth, Andrew (US SSA) <"Macbeth,>
Date: Thu, 14 Feb 2013 16:11:15 +0000

I have a jersey REST app running with Grizzly. The app is jar'd up via maven. I have a static .html file that I want to be able to serve. The file is packaged into the root of the .jar file. I can't figure out how to tell Grizzly to look into the jar file.

The root of the .jar file
/com
/META-INF
test.html


From main():
                              ResourceConfig resourceConfig = new PackagesResourceConfig("com.xyz.demo");
                              httpServer = GrizzlyServerFactory.createHttpServer(uri, resourceConfig);
                              StaticHttpHandler staticHttpHandler = new StaticHttpHandler("/");
                              httpServer.getServerConfiguration().addHttpHandler(staticHttpHandler, "/static");

From pom.xml:
                              <dependency>
                                             <groupId>com.sun.jersey</groupId>
                                             <artifactId>jersey-grizzly2</artifactId>
                                             <version>1.17</version>
                              </dependency>


Andrew J. Macbeth