Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Serve resource directory as root

Hello,

I would like to serve all files in a resource directory as it was the
root directory and serve anything else on the real root directory.
For example if the resource dir is /data/html/ and contains file.html
I want to serve it on /file.html

I currently set the resource folder with :
    ctx.setResourceBase("resource:///data/html");
then, I specify all files manually :
    ctx.addServlet(new ServletHolder(new DefaultServlet()), "/file.html");
    ctx.addServlet(new ServletHolder(new DefaultServlet()), "/file2.html");
    ....
Finally, I serve all other files on root :
    /* The homepage */
    ctx.addServlet(new ServletHolder(new HomeServlet(linksForRoot)), "/*");
    ctx.addServlet(new ServletHolder(new HomeServlet(linksForRoot)),
"/index.htm");
    ctx.addServlet(new ServletHolder(new HomeServlet(linksForRoot)),
"/index.html");

Is there a better way to serve all files in a specific directory
without explicitly specify all of them one per one ?


In advance, thanks for your help,

-- 
Alexis R.


Back to the top