aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes default servlet?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "default servlet??" Watch "default servlet??" New topic
Author

default servlet??

Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
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


Thanks <br />Poonam Agarwal SCWCD 86%
Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
Is this concept related to the <welcome-file-list>???
Collins Mbianda
Ranch Hand

Joined: Aug 11, 2007
Posts: 259
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.


SCJP 5.0 | SCWCD 1.4
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42601
    
  65
Googling for "default servlet" will get you many results that describe what it means in the context of the Tomcat servlet container.


Ping & DNS - my free Android networking tools app
Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
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

Joined: Aug 11, 2007
Posts: 259
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

Joined: Aug 11, 2007
Posts: 259
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

Joined: May 12, 2008
Posts: 323
Thanks Collins, I got it
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: default servlet??