Categories
General

Jetty 6 welcome file: how to use a servlet to handle your welcome file

I ‘ported’ my Java web application from Tomcat to Jetty. Like any web application, I defined a ‘welcome file’ in the application’s web.xml file. The welcome-file directive specifies the URL to be loaded by default when someone requests the root of your application. The welcome file may be just a file or a JSP, e.g. index.html, or it may be a name that is mapped to a servlet’s url (through the element in web.xml).

In Tomcat, specifying something like

Code listing of web.xml file

will work just as you would expect. But in Jetty, it will not. Unless you provide a workaround. What the somewhat angrily written post says is this: If you map a servlet to the URL index.htm, a file called index.htm must still exist. You *must* have a static, even empty, file called index.htm to have Jetty pass the request to your servlet that is mapped to that URL. Sorta cludgy, glad I found the answer quickly. Hope this helps others.

Share

Leave a Reply

Your email address will not be published.

 

Share