By default, yes, welcome files do need to exist. But Jetty can be configured to allow dispatching to welcome files which are servlets.
The welcome file mechanism allows a request to /some/directory/ to be served by the contents of a file like /some/directory/index.html. If there is a servlet mapped to handle the welcome file, it will be called. So if index.jsp is configured as a welcome file, then a request to /some/directory/ will be passed to the JspServlet mapped at
*.jsp to handle the /some/directory/index.jsp file.
From Jetty 6.1.16 onwards, the DefaultServlet can dispatch to welcome files which are servlets, even if the files don't exist. However, in order to allow directory listing when the servlet mapping matches, but would point to a nonexistent resource, by default this ability is disabled.
The options related to viewing directories and welcome files are as follows:
dirAllowedinit-param, if true, allows directory listings when the request matches no resources or servlets. Default in
welcomeServletsinit-param, if true, allows for dispatching to welcome files which are servlets even with no accompanying static resource. Default in
Assuming JSPServlet is called for requests to any file *.jsp, and
dirAllowed is true, then the behavior is as follows:
welcomeServlets option, with no existing index.jsp
404s, because it matches against *.jsp in the servlet mapping and dispatches to index.jsp
directory listing, because it doesn't try to dispatch to the JSP servlet
In older versions of Jetty, the file MUST exist for the welcome file mechanism to work. Even if index.do is defined as a welcome file, then a request to /some/directory/ will not be passed to a servlet handling
*.do for some/directory/index.do unless the file exists.
If your welcome-file-list is a mix of static resources and servlets, note that static resources will always take priority, in the order listed in the welcome-file-list. If no static resources match, then the welcome-file-list is checked again for any matching servlet mappings. This is to avoid any issues, such as above, where a webapp with no file index.jsp will return a 404 if index.jsp is in the welcome-file-list.
Note that the default welcome-file-list contains index.jsp.
If you want an index to be served by a servlet, then I suggest you use a filter to do the redirection. See the WelcomeFilter.java for an example.
In order to use a struts action as a welcome file, you will need to set
redirectWelcome in Default Servlet to
true. The default is for
redirectWelcome to be
false, which means the page will be forwarded to, and the action never called.