5.7. Specifying Welcome Pages

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> ...

Get More Servlets and JavaServer Pages™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.