2 Minutes To Code (β Version)

Apache Tomcat - 2 minute tutorial

How to configure welcome files for a web app

If you web-app's name (war file name) is myApp.war and it has a jsp user.jsp, then the url that client's have to hit to access it is http://ip:port/myApp/a.jsp. However, if clients hit the url http://ip:port/myApp then then tomcat will give either a 404 http status code error or list the contents of the web-app's root folder based on configuration.

Typically, when users come to a website, they just use the website's name as the url, so it is a good practice to serve some content from this url. This is where the <welcome-file-list> of th web.xml helps. When users use the website name as url, then tomcat looks up the <welcome-file> element and tries to serve the first available file mentioned in <welcome-file> elements. Hence, the name welcome file.