cours0708/P51/apache-tomcat-6.0.14/webapps/docs/funcspecs/printer/fs-default.html

225 lines
13 KiB
HTML
Raw Normal View History

2008-11-25 21:11:16 +00:00
<html><head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Catalina Functional Specifications - Default Servlet</title><meta name="author" value="Craig McClanahan"><meta name="email" value="craigmcc@apache.org"></head><body bgcolor="#ffffff" text="#000000" link="#525D76" alink="#525D76" vlink="#525D76"><table border="0" width="100%" cellspacing="0"><!--PAGE HEADER--><tr><td><!--PROJECT LOGO--><a href="http://tomcat.apache.org/"><img src="../../../images/tomcat.gif" align="right" alt="
Catalina Functional Specifications
" border="0"></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 src="../../../images/asf-logo.gif" align="right" alt="Apache Logo" border="0"></a></td></tr></table><table border="0" width="100%" cellspacing="4"><!--HEADER SEPARATOR--><tr><td colspan="2"><hr noshade="noshade" size="1"></td></tr><tr><!--RIGHT SIDE MAIN BODY--><td width="80%" valign="top" align="left"><table border="0" width="100%" cellspacing="4"><tr><td align="left" valign="top"><h1>Catalina Functional Specifications</h1><h2>Default Servlet</h2></td><td align="right" valign="top" nowrap="true"><img src="../../../images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Overview"><strong>Overview</strong></a></font></td></tr><tr><td><blockquote>
<table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Introduction"><strong>Introduction</strong></a></font></td></tr><tr><td><blockquote>
<p>The purpose of the <strong>Default Servlet</strong> is to serve
static resources of a web application in response to client requests.
As the name implies, it is generally configured as the "default"
servlet for a web application, by being mapped to a URL pattern "/".</p>
</blockquote></td></tr></table>
<table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="External Specifications"><strong>External Specifications</strong></a></font></td></tr><tr><td><blockquote>
<p>The following external specifications have provisions which
partially define the correct behavior of the default servlet:</p>
<ul>
<li><a href="http://java.sun.com/products/servlet/download.html">
Servlet Specification</a> (Version 2.3 PFD2)</li>
<li><a href="http://www.rfc-editor.org/rfc/rfc2046.txt">Multipurpose
Internet Mail Extensions (MIME) Part Two: Media Types</a></li>
<li><a href="http://www.rfc-editor.org/rfc/rfc2616.txt">Hypertext
Transfer Protocol -- HTTP/1.1</a></li>
</ul>
</blockquote></td></tr></table>
<table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Implementation Requirements"><strong>Implementation Requirements</strong></a></font></td></tr><tr><td><blockquote>
<p>The implementation of this functionality shall conform to the
following requirements:</p>
<ul>
<li>Must be implemented as a servlet.</li>
<li>Must support configurable parameters for debugging detail level,
input buffer size, output buffer size, whether or not to produce
directory listings when no welcome file is present, and whether or not
modifications are supported via DELETE and PUT.</li>
<li>Log debugging and operational messages (suitably internationalized)
via the <code>getServletContext().log()</code> method.</li>
</ul>
</blockquote></td></tr></table>
</blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Dependencies"><strong>Dependencies</strong></a></font></td></tr><tr><td><blockquote>
<table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Environmental Dependencies"><strong>Environmental Dependencies</strong></a></font></td></tr><tr><td><blockquote>
<p>The following environmental dependencies must be met in order for
the default servlet to operate correctly:</p>
<ul>
<li>The default servlet must be registered in the application deployment
descriptor (or the default deployment descriptor in file
<code>$CATALINA_HOME/conf/web.xml</code>) using a "default servlet"
servlet mapping, signified by URL pattern "/".</li>
</ul>
</blockquote></td></tr></table>
<table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Container Dependencies"><strong>Container Dependencies</strong></a></font></td></tr><tr><td><blockquote>
<p>Correct operation of the default servlet depends on the following
specific features of the surrounding container:</p>
<ul>
<li>The container shall provide a servlet context attribute that
lists the welcome file names that have been defined for this
web application.</li>
<li>The container shall provide a servlet context attribute that
contains a <code>javax.naming.directory.DirContext</code>
implementation representing the static resources of this
web application.</li>
</ul>
</blockquote></td></tr></table>
</blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Functionality"><strong>Functionality</strong></a></font></td></tr><tr><td><blockquote>
<table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Initialization Functionality"><strong>Initialization Functionality</strong></a></font></td></tr><tr><td><blockquote>
<p>The following processing must be performed when the <code>init()</code>
method of the invoker servlet is called:</p>
<ul>
<li>Process and sanity check configuration parameters.</li>
</ul>
</blockquote></td></tr></table>
<table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Per-Request Functionality"><strong>Per-Request Functionality</strong></a></font></td></tr><tr><td><blockquote>
<p>For all HTTP request methods, the resource path is determined from
the path information provided to this request, either as request attribute
<code>javax.servlet.include.path_info</code> (for a request dispatcher
access to a static resource) or by calling
<code>request.getPathInfo()</code> directly.</p>
<p>On each HTTP DELETE request processed by this servlet, the following
processing shall be performed:</p>
<ul>
<li>If modifications to the static resources are not allowed (set by a
configuration parameter), return HTTP status 403 (forbidden).</li>
<li>If an attempt is made to delete a resource from <code>/META-INF</code>
or <code>/WEB-INF</code>, return HTTP status 403 (forbidden).</li>
<li>If the requested resource does not exist, return HTTP status 404
(not found)</li>
<li>Unbind the resource from the directory context containing the
static resources for this web application. If successful, return
HTTP status 204 (no content). Otherwise, return HTTP status 405
(method not allowed).</li>
</ul>
<p>On each HTTP GET request processed by this servlet, the following
processing shall be performed:</p>
<ul>
<li>If the request is for a resource under <code>/META-INF</code> or
<code>/WEB-INF</code>, return HTTP status 404 (not found).</li>
<li>If the requested resource does not exist, return HTTP status 404
(not found).</li>
<li>If the requested resource is not a directory, but the resource
path ends in "/" or "\", return HTTP status 404 (not found).</li>
<li>If the requested resource is a directory:
<ul>
<li>If the request path does not end with "/", redirect to a
corresponding path with "/" appended so that relative references
in welcome files are resolved correctly.</li>
<li>If one of the specified welcome files exists, redirect to the
path for that welcome file so that it will be served explicitly.
</li>
</ul></li>
<li>If the request being processed contains an <code>If-Range</code>
header, perform the processing described in the HTTP/1.1 specification
to determine whether the client's information is up to date.</li>
<li>Determine the content type of the response, by looking up the
corresponding MIME type in our servlet context.</li>
<li>If the requested resource is a directory:
<ul>
<li>If directory listings are suppressed, return HTTP status 404
(not found).</li>
<li>Set the content type to <code>text/html</code>.</li>
</ul></li>
<li>Determine the range(s) to be returned, based on the existence of
any <code>If-Range</code> and <code>Range</code> headers.</li>
<li>If the requested resource is a directory, include an <code>ETag</code>
header in the response, with the value calculated based on the content
of the directory.</li>
<li>Include a <code>Last-Modified</code> header in the response documenting
the date/time that the resource was last modified.</li>
<li>Unless we are processing a HEAD request, include the appropriate
content (or content ranges) in the response.</li>
</ul>
<p>On each HTTP HEAD request processed by this servlet, the following
processing shall be performed:</p>
<ul>
<li>Processed identically to an HTTP GET request, except that the data
content is not transmitted after the headers.</li>
</ul>
<p>On each HTTP POST request processed by this servlet, the following
processing shall be performed:</p>
<ul>
<li>Processed identically to an HTTP GET request.</li>
</ul>
<p>On each HTTP PUT request processed by this servlet, the following
processing shall be perfomred:</p>
<ul>
<li>If modifications to the static resources are not allowed (set by a
configuration parameter), return HTTP status 403 (forbidden).</li>
<li>If an attempt is made to delete a resource from <code>/META-INF</code>
or <code>/WEB-INF</code>, return HTTP status 403 (forbidden).</li>
<li>Create a new resource from the body of this request.</li>
<li>Bind or rebind the specified path to the new resource (depending on
whether it currently exists or not). Return HTTP status as follows:
<ul>
<li>If binding was unsuccessful, return HTTP status 409 (conflict).
</li>
<li>If binding was successful and the resource did not previously
exist, return HTTP status 201 (created).</li>
<li>If binding was successful and the resource previously existed,
return HTTP status 204 (no content).</li>
</ul></li>
</ul>
</blockquote></td></tr></table>
<table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Finalization Functionality"><strong>Finalization Functionality</strong></a></font></td></tr><tr><td><blockquote>
<p>No specific processing is required when the <code>destroy()</code>
method is called:</p>
</blockquote></td></tr></table>
</blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Testable Assertions"><strong>Testable Assertions</strong></a></font></td></tr><tr><td><blockquote>
<p>In addition the the assertions implied by the functionality requirements
listed above, the following additional assertions shall be tested to
validate the behavior of the invoker servlet:</p>
<ul>
<li>Requests for resources that do not exist in the web application must
return HTTP status 404 (not found).</li>
<li>The default servlet must operate identically for web applications that
are run out of a WAR file directly, or from an unpacked directory
structure.</li>
<li>If the web application is running out of an unpacked directory
structure, the default servlet must recognize cases where the resource
has been updated through external means.</li>
</ul>
</blockquote></td></tr></table></td></tr><!--FOOTER SEPARATOR--><tr><td colspan="2"><hr noshade="noshade" size="1"></td></tr><!--PAGE FOOTER--><tr><td colspan="2"><div align="center"><font color="#525D76" size="-1"><em>
Copyright &copy; 1999-2006, Apache Software Foundation
</em></font></div></td></tr></table></body></html>