Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

default servlet??

 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello ranchers,

what is default servlet is all about. I just getting sick of reading the term "default servlet of the application" . I have read this term in so many topics like "mapping request to servlets/URL mapping", Exception handling etc..


please help
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this concept related to the <welcome-file-list>???
 
Collins Mbianda
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Poonam,

You can have a webApp without any servlet.
can you send a reference to on of the topic ? In that way we can undestand the context.

 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Googling for "default servlet" will get you many results that describe what it means in the context of the Tomcat servlet container.
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Googling for "default servlet" will get you many results that describe what it means in the context of the Tomcat servlet container.

'
Well Ulf,

what I understood by doing this search, that I might have the right knowledge of "default servlet". Googling specify any url-pattern which cotains exactly '/' slash is mapped to a default servlet OR rather this is the way to declare default servlet.

As per my knowledge url contains only "/" slashs are served by the static file or servlet listed by <welcome-file-list>

Am I right??? please correct if not

Thanks
 
Collins Mbianda
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Googling for "default servlet" will get you many results that describe what it means in the context of the Tomcat servlet container.


I understand know the concept:


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>

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?
* You can override it, to provide your own handler
* You can use it to enable or disable the Directory Listings Feature of Tomcat

 
Collins Mbianda
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Poonam Agarwal wrote:
As per my knowledge url contains only "/" slashs are served by the static file or servlet listed by <welcome-file-list>
Am I right??? please correct if not
Thanks


I think the Default Servlet will be called if no <welcome-file> page is found and the listing directory is enabled.
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Collins, I got it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic