Tomcat Welcome file list Tomcat directory listing setup welcome files in tomcat

Setup Welcome File List

When we type the URL till the project name only,we get the directory listing of the project folders.To avoid this we can setup the welcome files,which acts the the default welcome page when we type the url till project folder.We can use this facility provided by the tomcat folder when we want to display something like a login page or welcome page as the default or first page for the website and check other pages to be in session so that the user once logins then only he/she can traverse through different views of the site.The entry for the welcome file can be done in the delpoyment descriptor,i.e. Web.xml file .The sample is given below :


Here we can see that,when the url for till the project folder is hit in the browser,the welcome file is displayed.We can write as many welcome files in the <welcome-file-list> tag.The container first looks up for the first file to be present.If it exists it is displayed instead the container searches for the second entry.If not found it searches for the next page and so on till it finds one or els page not found error is thrown.However,to enable directory listing we can either edit the containers web.xml file which lies in the CATALINA_HOME/conf,or we can can edit our application specific web.xml file.In the server`s web.xml file we need to edit listings init param value for DefaultServlet entry as true.For the application specific purpose we need to override the DefaultServlet behaviour by making a sparate entry in the servlet tag for DeafaultServlet and making the listings init param as true.The snippet from the application`s web.xml file illustrates this:

<!-- Enable directory listings by overriding the server`s default web.xml file -->
<!-- The default servlet →


<!-- Add a mapping for our new default servlet -->

It must be noted that the entry in the servlet-name tag for the DefaultServlet be different in the container`s web.xml file and the application`s web.xml file otherwise a conflict will occur.

Number of View :9818


  1. No comments yet.

Content Protected Using Blog Protector By: PcDrome.