![]() |
![]() |
||||
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:
http://yoursite.com/ http://yoursite.com/images
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):
<servlet> <servlet-name>default</servlet-name> <servlet-class> org.apache.catalina.servlets.DefaultServlet </servlet-class> <init-param> <param-name>debug</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>listings</param-name> <param-value>false</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet>
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 --> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>