disable directory listing in tomcat

How to disable directory listing in Tomcat? + cPanel server ?
Ans :
By default the directory listing is enabled on the tomcat  server. You can disable it by using the following steps.
There are basically 2 methods of “turning off” this option :
* Create an index.jsp  file and place it in the web application’s directory ( under the document root )
* Edit the global web.xml file to turn off the option.
If you want to disable the directory listing for single domain then chose the first option but if you want to disable it server wide or all all account which is hosted on the server then choose the second option.
First option is simple , you need to create the index.jsp page  or index.php page under the document root of the domain name . When you have access the domain name then it shows index.jsp or index.html page.
And for the second option you need to change the default server web.xml file
1. Open the  web.xml file.
vi /usr/local/jakarta/tomcat/conf/web.xml
2. Look for the <init-param> section within the <servlet section>
3. Change the <param-value> to false for the <param-name>listing</param-name> section.
Restart the tomcat service on the server.

Related posts