Switch the tomcat listings options

This post is about how to override default tomcat options for each apps. For the default settings we used for tomcat will listings the directories when there is no feasible welcome pages. But we want to do separate settings for each apps.

After some search, according to this page: EnablingOrDisablingDirectoryListingsUsingWeb.xml, the answer is clear. That is, opening the configure file (web.xml) in what we want set up, and add the corresponding  <servlet> and <servlet-mapping> section as the example below.

<servlet>
<servlet-name>DefaultServletOverride</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<!– Add a mapping for our new default servlet –>
<servlet-mapping>
<servlet-name>DefaultServletOverride</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

Then finished.

Leave a Reply

Your email address will not be published. Required fields are marked *