welcome file list servlet
In Java servlets, the welcome-file-list
is used to specify the default web page that will be displayed to a user when they visit a web application. The welcome-file-list
is defined in the web.xml
file, which is the deployment descriptor for a Java web application.
To specify a welcome-file-list
in a web.xml
file, you need to add the following code:
<welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.jsp</welcome-file> </welcome-file-list>
In this example, the welcome-file-list
is defined with two welcome files - index.html
and index.jsp
. If a user visits the root URL of the web application (e.g., http://localhost:8080/myapp/), the server will look for the welcome files specified in the welcome-file-list
in the order they are listed. If the first file (index.html
in this case) is not found, the server will try the second file (index.jsp
).
It's important to note that the welcome-file-list
is optional, and if it is not defined, the server will typically use a default file (such as index.html
) as the welcome file.