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

Core Approach

Make welcome-file-list a standard entry in your web.xml files.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.230.81