Reputation: 43
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 http://localhost:8080/server-name/ in the browser like this:
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.
So far I've come to this method by adding security-constraint in web.xml:
<security-constraint>
<web-resource-collection>
<web-resource-name>precluded methods</web-resource-name>
<url-pattern>/css/*</url-pattern>
<url-pattern>/font/*</url-pattern>
<url-pattern>/img/*</url-pattern>
<url-pattern>/libs/*</url-pattern>
<url-pattern>/mock/*</url-pattern>
<url-pattern>/modules/*</url-pattern>
<url-pattern>/subpage/*</url-pattern>
<url-pattern>/util/*</url-pattern>
</web-resource-collection>
<auth-constraint />
</security-constraint>
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?
Upvotes: 1
Views: 1880
Reputation: 43
Like @josivan & @Joakim said all I need to do is to add a default servlet and set the flag to false
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.mortbay.jetty.servlet.DefaultServlet</servlet-class>
<init-param>
<param-name>dirAllowed</param-name>
<param-value>false</param-value>
</init-param>
</servlet>
Posting the detailed answer here.
Upvotes: 0
Reputation: 2073
Are you able to edit your web.xml
?
In case positive, add this snippet
<init-param>
<param-name>dirAllowed</param-name>
<param-value>false</param-value>
</init-param>
Upvotes: 2