source: nutchez-0.1/tomcat/webapps/docs/default-servlet.html @ 66

Last change on this file since 66 was 66, checked in by waue, 15 years ago

NutchEz - an easy way to nutch

File size: 17.3 KB
Line 
1<html><head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Apache Tomcat 6.0 - Default Servlet Reference</title><meta value="Tim Funk" name="author"><meta value="funkman@apache.org" name="email"></head><body vlink="#525D76" alink="#525D76" link="#525D76" text="#000000" bgcolor="#ffffff"><table cellspacing="0" width="100%" border="0"><!--PAGE HEADER--><tr><td><!--PROJECT LOGO--><a href="http://tomcat.apache.org/"><img border="0" alt="
2      The Apache Tomcat Servlet/JSP Container
3    " align="right" src="./images/tomcat.gif"></a></td><td><font face="arial,helvetica,sanserif"><h1>Apache Tomcat 6.0</h1></font></td><td><!--APACHE LOGO--><a href="http://www.apache.org/"><img border="0" alt="Apache Logo" align="right" src="./images/asf-logo.gif"></a></td></tr></table><table cellspacing="4" width="100%" border="0"><!--HEADER SEPARATOR--><tr><td colspan="2"><hr size="1" noshade></td></tr><tr><!--LEFT SIDE NAVIGATION--><td nowrap="true" valign="top" width="20%"><p><strong>Links</strong></p><ul><li><a href="index.html">Docs Home</a></li><li><a href="http://wiki.apache.org/tomcat/FAQ">FAQ</a></li></ul><p><strong>User Guide</strong></p><ul><li><a href="introduction.html">1) Introduction</a></li><li><a href="setup.html">2) Setup</a></li><li><a href="appdev/index.html">3) First webapp</a></li><li><a href="deployer-howto.html">4) Deployer</a></li><li><a href="manager-howto.html">5) Manager</a></li><li><a href="realm-howto.html">6) Realms and AAA</a></li><li><a href="security-manager-howto.html">7) Security Manager</a></li><li><a href="jndi-resources-howto.html">8) JNDI Resources</a></li><li><a href="jndi-datasource-examples-howto.html">9) JDBC DataSources</a></li><li><a href="class-loader-howto.html">10) Classloading</a></li><li><a href="jasper-howto.html">11) JSPs</a></li><li><a href="ssl-howto.html">12) SSL</a></li><li><a href="ssi-howto.html">13) SSI</a></li><li><a href="cgi-howto.html">14) CGI</a></li><li><a href="proxy-howto.html">15) Proxy Support</a></li><li><a href="mbeans-descriptor-howto.html">16) MBean Descriptor</a></li><li><a href="default-servlet.html">17) Default Servlet</a></li><li><a href="cluster-howto.html">18) Clustering</a></li><li><a href="balancer-howto.html">19) Load Balancer</a></li><li><a href="connectors.html">20) Connectors</a></li><li><a href="monitoring.html">21) Monitoring and Management</a></li><li><a href="logging.html">22) Logging</a></li><li><a href="apr.html">23) APR/Native</a></li><li><a href="virtual-hosting-howto.html">24) Virtual Hosting</a></li><li><a href="aio.html">25) Advanced IO</a></li><li><a href="extras.html">26) Additional Components</a></li><li><a href="maven-jars.html">27) Mavenized</a></li></ul><p><strong>Reference</strong></p><ul><li><a href="RELEASE-NOTES.txt">Release Notes</a></li><li><a href="config/index.html">Configuration</a></li><li><a href="api/index.html">Javadocs</a></li><li><a href="http://tomcat.apache.org/connectors-doc/">JK 1.2 Documentation</a></li></ul><p><strong>Apache Tomcat Development</strong></p><ul><li><a href="building.html">Building</a></li><li><a href="changelog.html">Changelog</a></li><li><a href="http://wiki.apache.org/tomcat/TomcatVersions">Status</a></li><li><a href="developers.html">Developers</a></li><li><a href="architecture/index.html">Architecture</a></li><li><a href="funcspecs/index.html">Functional Specs.</a></li></ul></td><!--RIGHT SIDE MAIN BODY--><td align="left" valign="top" width="80%"><table cellspacing="4" width="100%" border="0"><tr><td valign="top" align="left"><h1>Apache Tomcat 6.0</h1><h2>Default Servlet Reference</h2></td><td nowrap="true" valign="top" align="right"><small><a href="printer/default-servlet.html"><img alt="Printer Friendly Version" border="0" src="./images/printer.gif"><br>print-friendly<br>version
4                    </a></small></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Introduction"><strong>Introduction</strong></a></font></td></tr><tr><td><blockquote>
5
6This discusses different ways to manipulate the default servlet. Topics are
7<ul>
8  <li><a href="#what">What is the DefaultServlet?</a></li>
9  <li><a href="#where">Where is it declared?</a></li>
10  <li><a href="#change">What can I change?</a></li>
11  <li><a href="#dir">How do I customize directory listings?</a></li>
12  <li><a href="#secure">How do I secure directory listings?</a></li>
13
14</ul>
15
16</blockquote></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="What is the DefaultServlet"><strong>What is the DefaultServlet</strong></a></font></td></tr><tr><td><blockquote>
17<a name="what"></a>
18The default servlet is the servlet which serves static resources as well
19as serves the directory listings (if directory listings are enabled).
20
21</blockquote></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Where is it declared?"><strong>Where is it declared?</strong></a></font></td></tr><tr><td><blockquote>
22<a name="where"></a>
23It is declared globally in <i>$CATALINA_BASE/conf/web.xml</i>.
24By default here is it's declaration:
25<div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre>
26    &lt;servlet&gt;
27        &lt;servlet-name&gt;default&lt;/servlet-name&gt;
28        &lt;servlet-class&gt;
29          org.apache.catalina.servlets.DefaultServlet
30        &lt;/servlet-class&gt;
31        &lt;init-param&gt;
32            &lt;param-name&gt;debug&lt;/param-name&gt;
33            &lt;param-value&gt;0&lt;/param-value&gt;
34        &lt;/init-param&gt;
35        &lt;init-param&gt;
36            &lt;param-name&gt;listings&lt;/param-name&gt;
37            &lt;param-value&gt;true&lt;/param-value&gt;
38        &lt;/init-param&gt;
39        &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
40    &lt;/servlet&gt;
41
42...
43
44    &lt;servlet-mapping&gt;
45        &lt;servlet-name&gt;default&lt;/servlet-name&gt;
46        &lt;url-pattern&gt;/&lt;/url-pattern&gt;
47    &lt;/servlet-mapping&gt;
48
49</pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td></tr></table></div>
50
51So by default, the default servlet is loaded at webapp startup and
52directory listings are enabled and debugging is turned off.
53</blockquote></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="What can I change?"><strong>What can I change?</strong></a></font></td></tr><tr><td><blockquote>
54<a name="change"></a>
55The DefaultServlet allows the following initParamters:
56
57<table border="1">
58  <tr>
59    <th valign="top">debug</th>
60    <td valign="top">
61        Debugging level. It is not very useful unless you are a tomcat
62        developer. As
63        of this writing, useful values are 0, 1, 11, 1000.
64    </td>
65  </tr>
66  <tr>
67    <th valign="top">listings</th>
68    <td valign="top">
69        If no welcome file is present, can a directory listing be
70        shown?
71        value may be <b>true</b> or <b>false</b>
72        <br>
73        Welcome files are part of the servlet api.
74        <br>
75        <b>WARNING:</b> Listings of directories containing many entries are
76        expensive. Multiple requests for large directory listings can consume
77        significant proportions of server resources.
78    </td>
79  </tr>
80  <tr>
81    <th valign="top">readmeFile</th>
82    <td valign="top">
83        If a directory listing is presented, a readme file may also
84        be presented with the listing. This file is inserted as is
85        so it may contain HTML. default value is null
86    </td>
87  </tr>
88  <tr>
89    <th valign="top">globalXsltFile</th>
90    <td valign="top">
91        If you wish to customize your directory listing, you
92        can use an XSL transformation. This value is an absolute
93        file name which be used for all direcotory listings.
94        This can be disabled by per webapp by also declaring the
95        default servlet in your local webapp's web.xml. The format
96        of the xml is shown below.
97    </td>
98  </tr>
99  <tr>
100    <th valign="top">localXsltFile</th>
101    <td valign="top">
102        You may also customize your directory listing by directory by
103        configuring <code>localXsltFile</code>. This should be a relative
104        file name in the directory where the listing will take place.
105        This overrides <code>globalXsltFile</code>. If this value
106        is present but a file does not exist, then
107        <code>globalXsltFile</code> will be used. If
108        <code>globalXsltFile</code> does not exist, then the default
109        directory listing will be shown.
110    </td>
111  </tr>
112  <tr>
113    <th valign="top">input</th>
114    <td valign="top">
115        Input buffer size (in bytes) when reading
116        resources to be served.  [2048]
117    </td>
118  </tr>
119  <tr>
120    <th valign="top">output</th>
121    <td valign="top">
122        Output buffer size (in bytes) when writing
123        resources to be served.  [2048]
124    </td>
125  </tr>
126  <tr>
127    <th valign="top">readonly</th>
128    <td valign="top">
129        Is this context "read only", so HTTP commands like PUT and
130        DELETE are rejected?  [true]
131    </td>
132  </tr>
133  <tr>
134    <th valign="top">fileEncoding</th>
135    <td valign="top">
136        File encoding to be used when reading static resources.
137        [platform default]
138    </td>
139  </tr>
140  <tr>
141    <th valign="top">sendfileSize</th>
142    <td valign="top">
143        If the connector used supports sendfile, this represents the minimal
144        file size in KB for which sendfile will be used. Use a negative value
145        to always disable sendfile. [48]
146    </td>
147  </tr>
148
149</table>
150</blockquote></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="How do I customize directory listings?"><strong>How do I customize directory listings?</strong></a></font></td></tr><tr><td><blockquote>
151<a name="dir"></a>
152<p>You can override DefaultServlet with you own implementation and use that
153in your web.xml declaration. If you
154can undertand what was just said, we will assume yo can read the code
155to DefaultServlet servlet and make the appropriate adjustments. (If not,
156then that method isn't for you)
157</p>
158<p>
159You can use either  <code>localXsltFile</code> or
160<code>globalXsltFile</code> and DefaultServlet will create
161an xml document and run it through an xsl transformation based
162on the values provided in <code>localXsltFile</code> and
163<code>globalXsltFile</code>. <code>localXsltFile</code> is first
164checked, followed by <code>globalXsltFile</code>, then default
165behaviors takes place.
166</p>
167
168<p>
169Format:
170<div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre>
171    &lt;listing&gt;
172     &lt;entries&gt;
173      &lt;entry type='file|dir' urlPath='aPath' size='###' date='gmt date'&gt;
174        fileName1
175      &lt;/entry&gt;
176      &lt;entry type='file|dir' urlPath='aPath' size='###' date='gmt date'&gt;
177        fileName2
178      &lt;/entry&gt;
179      ...
180     &lt;/entries&gt;
181     &lt;readme&gt;&lt;/readme&gt;
182    &lt;/listing&gt;
183</pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td></tr></table></div>
184<ul>
185  <li>size will be missing if <code>type='dir'</code></li>
186  <li>Readme is a CDATA entry</li>
187</ul>
188</p>
189The following is a sample xsl file which mimics the default tomcat behavior:
190<div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre>
191&lt;?xml version="1.0"?&gt;
192
193&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
194  version="1.0"&gt;
195
196  &lt;xsl:output method="xhtml" encoding="iso-8859-1" indent="no"/&gt;
197
198  &lt;xsl:template match="listing"&gt;
199   &lt;html&gt;
200    &lt;head&gt;
201      &lt;title&gt;
202        Sample Directory Listing For
203        &lt;xsl:value-of select="@directory"/&gt;
204      &lt;/title&gt;
205      &lt;style&gt;
206        h1{color : white;background-color : #0086b2;}
207        h3{color : white;background-color : #0086b2;}
208        body{font-family : sans-serif,Arial,Tahoma;
209             color : black;background-color : white;}
210        b{color : white;background-color : #0086b2;}
211        a{color : black;} HR{color : #0086b2;}
212      &lt;/style&gt;
213    &lt;/head&gt;
214    &lt;body&gt;
215      &lt;h1&gt;Sample Directory Listing For
216            &lt;xsl:value-of select="@directory"/&gt;
217      &lt;/h1&gt;
218      &lt;hr size="1" /&gt;
219      &lt;table cellspacing="0"
220                  width="100%"
221            cellpadding="5"
222                  align="center"&gt;
223        &lt;tr&gt;
224          &lt;th align="left"&gt;Filename&lt;/th&gt;
225          &lt;th align="center"&gt;Size&lt;/th&gt;
226          &lt;th align="right"&gt;Last Modified&lt;/th&gt;
227        &lt;/tr&gt;
228        &lt;xsl:apply-templates select="entries"/&gt;
229        &lt;/table&gt;
230      &lt;xsl:apply-templates select="readme"/&gt;
231      &lt;hr size="1" /&gt;
232      &lt;h3&gt;Apache Tomcat/6.0&lt;/h3&gt;
233    &lt;/body&gt;
234   &lt;/html&gt;
235  &lt;/xsl:template&gt;
236
237
238  &lt;xsl:template match="entries"&gt;
239    &lt;xsl:apply-templates select="entry"/&gt;
240  &lt;/xsl:template&gt;
241
242  &lt;xsl:template match="readme"&gt;
243    &lt;hr size="1" /&gt;
244    &lt;pre&gt;&lt;xsl:apply-templates/&gt;&lt;/pre&gt;
245  &lt;/xsl:template&gt;
246
247  &lt;xsl:template match="entry"&gt;
248    &lt;tr&gt;
249      &lt;td align="left"&gt;
250        &lt;xsl:variable name="urlPath" select="@urlPath"/&gt;
251        &lt;a href="{$urlPath}"&gt;
252          &lt;tt&gt;&lt;xsl:apply-templates/&gt;&lt;/tt&gt;
253        &lt;/a&gt;
254      &lt;/td&gt;
255      &lt;td align="right"&gt;
256        &lt;tt&gt;&lt;xsl:value-of select="@size"/&gt;&lt;/tt&gt;
257      &lt;/td&gt;
258      &lt;td align="right"&gt;
259        &lt;tt&gt;&lt;xsl:value-of select="@date"/&gt;&lt;/tt&gt;
260      &lt;/td&gt;
261    &lt;/tr&gt;
262  &lt;/xsl:template&gt;
263
264&lt;/xsl:stylesheet&gt;
265</pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="./images/void.gif"></td></tr></table></div>
266
267</blockquote></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="How do I secure directory listings?"><strong>How do I secure directory listings?</strong></a></font></td></tr><tr><td><blockquote>
268<a name="secure"></a>
269Use web.xml in each individual webapp. See the security section of the
270Servlet specification.
271
272</blockquote></td></tr></table></td></tr><!--FOOTER SEPARATOR--><tr><td colspan="2"><hr size="1" noshade></td></tr><!--PAGE FOOTER--><tr><td colspan="2"><div align="center"><font size="-1" color="#525D76"><em>
273        Copyright &copy; 1999-2008, Apache Software Foundation
274        </em></font></div></td></tr></table></body></html>
Note: See TracBrowser for help on using the repository browser.