[undertow-dev] serving static files

Stuart Douglas sdouglas at redhat.com
Sun Feb 2 12:37:59 EST 2014


I just added a file serving example to the Undertow examples, can you try that out and let me know if it works for you?

Just get the latest Undertow, build the examples, then run:

mvn exec:exec 

And select the file serving one, it should serve up you home directory.

Stuart

----- Original Message -----
> From: "Matthias Wessendorf" <matzew at redhat.com>
> To: undertow-dev at lists.jboss.org
> Sent: Sunday, 2 February, 2014 1:58:14 PM
> Subject: [undertow-dev] serving static files
> 
> Hello,
> 
> I might be just doing it wrong, but the following attempts are not successful
> for serving static files from a folder:
> 
> 
>         UndertowJaxrsServer ut = new UndertowJaxrsServer();
>  
>         MyRestApplication app = new MyRestApplication();
>  
>         ut.deploy(app);
>  
>         ut.start(
>                 Undertow.builder()
>                         .addHttpListener(8080, "0.0.0.0")
> 
>  
>                 // first tried this:
>                         .setHandler(path()
>                                     .addPrefixPath("/",resource(new
>                                     FileResourceManager(new
>                                     File("/some/folder/containing/html/files"),
>                                     1024))))
>  
> 
>                 // afterwards also tried this:
>                         .setHandler(resource(new FileResourceManager(new
>                         File("/some/folder/containing/html/files"), 1024)))
>         );
>  
>         try {
>             Thread.currentThread().join();
>         }
>         catch (InterruptedException e) {
>             logger.info("shutting down");
>             ut.stop();
>         }
> 
> 
> 
> 
> Not sure, but none of the above handlers seems to server files from a folder
> on my box
> 
> 
> Greetings,
> Matthias
> 
> 
> 
> 
> 
> --
> Matthias Wessendorf
> matzew at redhat.com
> 
> JBoss, by Red Hat
> _______________________________________________
> undertow-dev mailing list
> undertow-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/undertow-dev
> 


More information about the undertow-dev mailing list