Mohit Agrawal
Mohit Agrawal

Reputation: 323

Disable directory listing in jetty

I am using jetty to deploy my web application. I have changed the webdefault.xml dirAllowed parameter to false, still jetty is listing all the contexts path inside it whenever I will give IP:PORT.

<init-param>
    <param-name>dirAllowed</param-name>
    <param-value>false</param-value>
</init-param>

Thanks in advance.

Upvotes: 0

Views: 1141

Answers (1)

Joakim Erdfelt
Joakim Erdfelt

Reputation: 49515

Don't modify the webdefault.xml directly, you have to provide your own copy of it, and specify its location in your context xml deployable ${jetty.base}/webapps/UserManagement.xml.

Example:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
                           "http://www.eclipse.org/jetty/configure_9_3.dtd">

<Configure id="testWebapp" class="org.eclipse.jetty.webapp.WebAppContext">

  <Set name="contextPath">/UserManagement</Set>
  <Set name="war">
    <Property name="jetty.webapps"/>/UserManagement.war
  </Set>

  <Set name="defaultsDescriptor">
    <Property name="jetty.base"/>/etc/mywebdefault.xml
  </Set>
</Configure>

A simpler solution is to modify your WEB-INF/web.xml in your UserManagement.war as outlined in the previous answer ...

https://stackoverflow.com/a/43328817/775715

Upvotes: 1

Related Questions