title: How do I prevent directory listing in Jetty?
body: <p>Basically I have this jetty server running at my local with a bunch of folder/files right under the root directory webapp/.
  Currently they can be accessed just by typing <a href="http://localhost:8080/server-name/" rel="nofollow noreferrer">http://localhost:8080/server-name/</a> in the browser like this:</p>
  
  <p><a href="https://i.stack.imgur.com/YavX8.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YavX8.jpg" alt="the static directory of the server"></a></p>
  
  <p>Obviously it looks very ugly when users goes to this root directory so I'm wondering if it is possible to block this page or mask it with some friendly message.</p>
  
  <p>So far I've come to this method by adding security-constraint in web.xml:</p>
  
  <pre><code>    &lt;security-constraint&gt;
      &lt;web-resource-collection&gt;
          &lt;web-resource-name&gt;precluded methods&lt;/web-resource-name&gt;
          &lt;url-pattern&gt;/css/*&lt;/url-pattern&gt;
          &lt;url-pattern&gt;/font/*&lt;/url-pattern&gt;
          &lt;url-pattern&gt;/img/*&lt;/url-pattern&gt;
          &lt;url-pattern&gt;/libs/*&lt;/url-pattern&gt;
          &lt;url-pattern&gt;/mock/*&lt;/url-pattern&gt;          
          &lt;url-pattern&gt;/modules/*&lt;/url-pattern&gt;
          &lt;url-pattern&gt;/subpage/*&lt;/url-pattern&gt;
          &lt;url-pattern&gt;/util/*&lt;/url-pattern&gt;          
      &lt;/web-resource-collection&gt;
      &lt;auth-constraint /&gt;
  &lt;/security-constraint&gt;
  </code></pre>
  
  <p>But apparently it would block the actual access to above jsp/folders from users and that is certainly not what I intended. 
  So is it possible to simply block/mask the page from users without any other affects?</p>