welcome-file-list:
The welcome-file-list attribute of the web.xml file is used to define the list of welcome files.
Sample code of welcome-file-list attribute in web.xml:
<web-app>
//other attributes
<welcome-file-list>
<welcome-file>home.html</welcome-file>
<welcome-file>welcome.html</welcome-file>
</welcome-file-list>
//other attributes
</web-app>
How it works:
The first web server looks for the welcome-file-list if it exists then it looks for the file defined in the first welcome-file. If this file exists then control is transferred to this file otherwise web server will look at the next welcome file and so on.
If the welcome-file-list does not exist or files defined in the welcome-file-list do not exist then the server will look at the default welcome files in the following order index.html, index.htm, index.jsp, default.html, default.htm, and default.jsp.
Default welcome file list:
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
Example of welcome-file-list:
web.xml
<!--?xml version="1.0" encoding="UTF-8"?-->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemalocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<welcome-file-list>
<welcome-file>welcome.html</welcome-file>
</welcome-file-list>
</web-app>
welcome.html
<title>welcome</title>
<h1>This is a welcome file list program.</h1>