Suppose a user supplies a URL like http://host/webAppPrefix/directoryName/ that contains a directory name but no filename. What happens? Does the user get a directory listing? An error? The contents of a standard file? If so, which one—index.html, index.jsp, default.html, default.htm, or what?
The welcome-file-list element, along with its subsidiary welcome-file element, resolves this ambiguity. For example, the following web.xml entry specifies that if a URL gives a directory name but no filename, the server should try index.jsp first and index.html second. If neither is found, the result is server specific (e.g., a directory listing).
<welcome-file-list> <welcome-file>index.jsp</welcome-file> <welcome-file>index.html</welcome-file> </welcome-file-list>
Although many servers follow this behavior by default, they are not required to do so. As a result, it is good practice to explicitly use welcome-file-list to ensure portability.
|
3.137.188.201