Welcome-file-list in web.xml by R4R Team

Welcome-file-list in web.xml file of Project:

The tag <welcome-file-list> is used for specifying the files that needs to be invoked by server by default, if you do not specify a file name while loading the project on browser.

For e.g. You have created a project named “MyServletProject” and you have few html pages and servlet classes defined in the project. However in browser you have given the url like this:

http://localhost:8888/MyServletProject
Generally we give the complete path like this http://localhost:8888/MyServletProject/index.html. However if you have given the path like above then the webserver will look for the <welcome-file-list> tag in your project’s web.xml file. Lets say you have below content in the web.xml file:

<web-app>

....

<welcome-file-list>

<welcome-file>myhome.htm</welcome-file>

<welcome-file>myindex.htm</welcome-file>

<welcome-file>mydefaultpage.htm</welcome-file>

</welcome-file-list>

....

</web-app>

Based on the welcome file list, server would look for the myhome.htm page if this doesn’t exist then the second welcome file myindex.html and so on till it finds a valid welcome file.

Note: If the <welcome-file-list> tag is not defined in web.xml or the welcome files defined in the <welcome-file> tags does not exist then the server would look for the following files in the given sequence:
1) index.html
2) index.htm
3) index.jsp

Leave a Comment:
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!