Message-ID: <1142314797.4899.1369485279411.JavaMail.email@example.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_4898_106375243.1369485279411" ------=_Part_4898_106375243.1369485279411 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
By default, yes, welcome files do need to exist. But Jetty can be config= ured to allow dispatching to welcome files which are servlets.
The welcome file mechanism allows a request to /some/directory/ to be s=
erved by the contents of a file like /some/directory/index.html. If there i=
s a servlet mapped to handle the welcome file, it will be called. So if ind=
ex.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=
From Jetty 6.1.16 onwards, the DefaultServlet can dispatch to welcome fi= les 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 foll= ows:
dirAllowedinit-param, if true, allows= directory listings when the request matches no resources or servlets. Defa= ult in
welcomeServletsinit-param, if true, a= llows for dispatching to welcome files which are servlets even with no acco= mpanying static resource. Default in
webdefault.xmlis false.<= /li>
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 ind= ex.jsp
404s, because it matches against *.jsp in th= e 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 ha=
*.do for some/directory/index.do unless the file exists=
If your welcome-file-list is a mix of static resources and servlets, not= e that static resources will always take priority, in the order listed in t= he welcome-file-list. If no static resources match, then the welcome-file-l= ist is checked again for any matching servlet mappings. This is to avoid an= y 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 We= lcomeFilter.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 def=
ault is for
redirectWelcome to be
false, which me=
ans the page will be forwarded to, and the action never called.