Re: [webbit] Serving static html file from inside jar

208 views
Skip to first unread message

aslak hellesoy

unread,
Jun 4, 2013, 5:14:10 PM6/4/13
to Webbit



On Sat, Jun 1, 2013 at 3:21 AM, pigna <pij...@home.nl> wrote:
I would like to deliver the webpage inside the jar.

However I don't know how to get that working. I have it working for external files but can't seem to get it working for files inside the jar.
Nothing more than one simple index.html

Can someone explain how to make Webbit serve a page from inside a jar?


Have you tried with the EmbeddedResourceHandler?

Aslak
 

--
You received this message because you are subscribed to the Google Groups "Webbit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webbit+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

pigna

unread,
Jun 19, 2013, 4:17:01 AM6/19/13
to web...@googlegroups.com
Yes but I'm somewhat confused how the path should look like to say the least ... :)
 
First I have everything running with the staticfilehandler
 

  this.webServer = WebServers.createWebServer(port)
         .add("/gui", wsh)
         .add(new StaticFileHandler("gui")
         );

My jar file layout looks like:

gui/index.html
META-INF
com/test/websocket/WebSocketServer.class
com/test/websocket/gui/WebSocketHandler.class

Is it possible to serve the index file in the gui folder from inside the jar. Or should index.html be placed differently ..
Tried this :
.add(new EmbeddedResourceHandler("/gui/index.html")

but that seems incorrect.
Any help is appreciated.

 

 

 

 

 

 

Op dinsdag 4 juni 2013 23:14:10 UTC+2 schreef Aslak Hellesøy het volgende:

Jose Gómez

unread,
May 12, 2014, 8:40:40 AM5/12/14
to web...@googlegroups.com
Did you manage to make it work with the below approach?

Jose Gómez

unread,
Jun 18, 2014, 7:14:31 PM6/18/14
to web...@googlegroups.com
Well, it turns out it is so easy as:

    server.add(new EmbeddedResourceHandler(path));

Where path can be something like "webroot" (for a root folder called "webroot")
Reply all
Reply to author
Forward
0 new messages