Html server grizzly + jersey (.html from .jar archive)

I want to serve my .html sites from a .jar archive, not from a folder. I am currently using grizzly (knitted) and serve static pages, for example:

HttpServer webServer; .... .... webServer.getServerConfiguration().addHttpHandler(new StaticHttpHandler("varwww"), "/app"); webServer.start(); 

Is there a way to make the web server not extract the .html from the "varwww" folder and get it from myhtml.jar?

+2
source share
1 answer

This feature is implemented in Grizzly 2.3.3+. Here is the correspondent question .

You can use the special CLStaticHttpHandler and pass the ClassLoader, which will be used to search for static resources. For instance:

 httpServer.getServerConfiguration().addHttpHandler( new CLStaticHttpHandler(new URLClassLoader(new URL[] {new URL("file:///home/username/staticfiles.jar")})), "/www"); 

Hope this helps.

+3
source

All Articles