Wednesday, April 21, 2010

How can we turn on the display of folders/directories in web browser which present under tomcat ROOT directory.

I downloaded apache tomcat server and added a folder repository in 'apache-tomcat-6.0.26\webapps\ROOT' directory which contains many subfolders/subdirectories and html pages, jars inside those folders/directories.
I can go index page in 'apache-tomcat-6.0.26\webapps\ROOT' folder by typing the URL as 'http://localhost:8080'

But now if I want to download any jar present in some subfolder of repository directory, I can do it by typing the relative path of the jar file and adding the URL.

Suppose x.jar is present in the directory 'repository\xx\yy\x.jar', then I can download it by accessing following URL : 'http://localhost:8080/repository/xx/yy/x.jar'

But I type something like 'http://localhost:8080/repository/xx/yy' it will give me error page.

If you want to turn on the display of directories/folders in the web browser in case the default file like index.html is not present, then it should display the list of files and directories present under that directory mentioned in the URL.

For enabling this, you have to set 'listings' parameter in the default servlet to true. You have to edit the web.xml flie present at location: 'apache-tomcat-6.0.26\conf' directory.

Set it as shown below:

<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>


Once you do this, You can see web browser will display the directory structure, the list of files and sub-directories present the directory mentioned in URL

No comments: