Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programmatically enable directory browsing for a particular path in Jetty 9.x?

Is it possible to programmatically enable directory browsing for a particular path in Jetty 9.x (and if "yes" -- how)?

like image 543
carlspring Avatar asked Dec 04 '25 17:12

carlspring


1 Answers

If you want to configure directory browsing through configuration (not programmatically) of the Web Application Deployment Descriptor (web.xml), you will need to configure a DefaultServlet. Here is an example:

<servlet>
    <servlet-name>default</servlet-name>
    <servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class>
    <init-param>
        <param-name>resourceBase</param-name>
        <param-value>/path/to/your/static/files</param-value>
    </init-param>
    <init-param>
        <param-name>dirAllowed</param-name>
        <param-value>true</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/path/to/serve/content/on/*</url-pattern>
</servlet-mapping>

See http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/servlet/DefaultServlet.html for details and additional configuration options.

like image 173
ironchefpython Avatar answered Dec 06 '25 06:12

ironchefpython