Metawerx Java Hosting Small Logo

Default Servlet

The Default servlet (or DefaultServlet) is a special servlet provided with Tomcat, which is called when no other suitable page is found in a particular folder.

For example, it will be called if the following folders are empty:

It's purpose is to display a directory listing, which may be enabled or disabled by modifying the "listings" parameter.

The definition for the Default Servlet is in the server-wide default web.xml file (<jakarta>/conf/web.xml). It looks like this (for Tomcat 5.5):


As you can see from the above, the servlet is built into one of the Apache libraries.
There is also a <servlet-mapping> tag which maps the servlet to the "/" url-mapping:

<!-- The mapping for the default servlet -->

When is the Default Servlet called?

  • The Default Servlet is called when no suitable <welcome-file> page is found in the folder. See the <welcome-file-list> tag for information on the exact sequence of events.

What can I do with the Default Servlet?

See Also

metawerx specific

referring pages