Is it possible to programmatically enable directory browsing for a particular path in Jetty 9.x (and if "yes" -- how)?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With