Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.catalina.servlets
Class DefaultServlet

    java.lang.Object
      javax.servlet.GenericServlet
          javax.servlet.http.HttpServlet
              org.apache.catalina.servlets.DefaultServlet

All Implemented Interfaces:
  java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

Direct Known Subclasses:
  WebdavServlet

public class DefaultServlet
extends javax.servlet.http.HttpServlet

The default resource-serving servlet for most web applications, used to serve static resources such as HTML pages and images.

Version:
  $Revision: 1.63 $ $Date: 2004/08/26 21:38:13 $
Author:
  Craig R. McClanahan, Remy Maucherat
See Also:
  Serialized Form

Nested Class Summary
`protected class` | `DefaultServlet.ResourceInfo`

Field Summary
`protected int` | `debug` The debugging detail level for this servlet.
`protected boolean` | `encodeRedirects` Calls encodeRedirectURL on redirects? default=false
`protected static java.text.SimpleDateFormat[]` | `formats` The set of SimpleDateFormat formats to use in getDateHeader().
`protected static java.util.TimeZone` | `gmtZone`
`protected int` | `input` The input buffer size to use when serving resources.
`protected boolean` | `listings` Should we generate directory listings when no welcome file is present?
`protected static MD5Encoder` | `md5Encoder` The MD5 helper object for this class.
`protected static java.security.MessageDigest` | `md5Helper` MD5 message digest provider.
`protected static java.lang.String` | `mimeSeparation` MIME multipart separation string
`protected int` | `output` The output buffer size to use when serving resources.
`protected boolean` | `readOnly` Read only flag.
`protected static java.lang.String` | `RESOURCES_JNDI_NAME` JNDI resources name.
`protected static StringManager` | `sm` The string manager for this package.
`protected static URLEncoder` | `urlEncoder` Array containing the safe characters set.
`protected java.lang.String[]` | `welcomes` The set of welcome files for this web application

Constructor Summary
`DefaultServlet()`

Method Summary
`protected java.lang.String` | `appendParameters(javax.servlet.http.HttpServletRequest request, java.lang.String redirectPath)` Append the request parameters to the redirection string before calling sendRedirect.
`protected boolean` | `checkIfHeaders(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, DefaultServlet.ResourceInfo resourceInfo)` Check if the conditions specified in the optional If headers are satisfied.
`void` | `destroy()` Finalize this servlet.
`protected void` | `displaySize(java.lang.StringBuffer buf, int filesize)` Display the size of a file.
`protected void` | `doDelete(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)` Process a POST request for the specified resource.
`protected void` | `doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)` Process a GET request for the specified resource.
`protected void` | `doHead(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)` Process a HEAD request for the specified resource.
`protected void` | `doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)` Process a POST request for the specified resource.
`protected void` | `doPut(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)` Process a POST request for the specified resource.
`protected java.io.File` | `executePartialPut(javax.servlet.http.HttpServletRequest req, org.apache.catalina.servlets.DefaultServlet.Range range, java.lang.String path)` Handle a partial PUT.
`protected java.lang.String` | `getETag(DefaultServlet.ResourceInfo resourceInfo)` Get the ETag associated with a file.
`protected java.lang.String` | `getRelativePath(javax.servlet.http.HttpServletRequest request)` Return the relative path associated with this servlet.
`protected javax.naming.directory.DirContext` | `getResources()` Get resources.
`void` | `init()` Initialize this servlet.
`protected java.lang.String` | `normalize(java.lang.String path)` Return a context-relative path, beginning with a "/", that represents the canonical version of the specified path after ".." and "." elements are resolved out.
`protected org.apache.catalina.servlets.DefaultServlet.Range` | `parseContentRange(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)` Parse the content-range header.
`protected java.util.Vector` | `parseRange(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, DefaultServlet.ResourceInfo resourceInfo)` Parse the range header.
`protected java.io.InputStream` | `render(java.lang.String contextPath, DefaultServlet.ResourceInfo resourceInfo)` Return an InputStream to an HTML representation of the contents of this directory.
`protected java.lang.String` | `renderSize(long size)` Render the specified file size (in bytes).
`protected java.lang.String` | `rewriteUrl(java.lang.String path)` URL rewriter.
`protected void` | `serveResource(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean content)` Serve the specified resource, optionally including the data content.
`protected void` | `showRequestInfo(javax.servlet.http.HttpServletRequest req)` Show HTTP header information.

Methods inherited from class javax.servlet.http.HttpServlet
`doOptions, doTrace, getLastModified, service, service`

Methods inherited from class javax.servlet.GenericServlet
`getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### debug

    protected int debug

  The debugging detail level for this servlet.

### input

    protected int input

  The input buffer size to use when serving resources.

### listings

    protected boolean listings

  Should we generate directory listings when no welcome file is present?

### readOnly

    protected boolean readOnly

  Read only flag. By default, it's set to true.

### output

    protected int output

  The output buffer size to use when serving resources.

### encodeRedirects

    protected boolean encodeRedirects

  Calls encodeRedirectURL on redirects? default=false

### welcomes

    protected java.lang.String[] welcomes

  The set of welcome files for this web application

### md5Helper

    protected static java.security.MessageDigest md5Helper

  MD5 message digest provider.

### md5Encoder

    protected static final MD5Encoder md5Encoder

  The MD5 helper object for this class.

### formats

    protected static final java.text.SimpleDateFormat[] formats

  The set of SimpleDateFormat formats to use in getDateHeader().

### gmtZone

    protected static final java.util.TimeZone gmtZone

### urlEncoder

    protected static URLEncoder urlEncoder

  Array containing the safe characters set.

### mimeSeparation

    protected static final java.lang.String mimeSeparation

  MIME multipart separation string

  See Also:
    Constant Field Values

### RESOURCES_JNDI_NAME

    protected static final java.lang.String RESOURCES_JNDI_NAME

  JNDI resources name.

  See Also:
    Constant Field Values

### sm

    protected static StringManager sm

  The string manager for this package.

Constructor Detail

### DefaultServlet

    public DefaultServlet()

Method Detail

### destroy

    public void destroy()

  Finalize this servlet.

### init

    public void init()
              throws javax.servlet.ServletException

  Initialize this servlet.

  Throws:
    `javax.servlet.ServletException`

### getResources

    protected javax.naming.directory.DirContext getResources()

  Get resources. This method will try to retrieve the resources through JNDI first, then in the servlet context if JNDI has failed (it could be disabled). It will return null.

  Returns:
    A JNDI DirContext, or null.

### showRequestInfo

    protected void showRequestInfo(javax.servlet.http.HttpServletRequest req)

  Show HTTP header information.

### getRelativePath

    protected java.lang.String getRelativePath(javax.servlet.http.HttpServletRequest request)

  Return the relative path associated with this servlet.

  Parameters:
    `request` - The servlet request we are processing

### doGet

    protected void doGet(javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response)
                  throws java.io.IOException,
                         javax.servlet.ServletException

  Process a GET request for the specified resource.

  Parameters:
    `request` - The servlet request we are processing
    `response` - The servlet response we are creating
  Throws:
    `java.io.IOException` - if an input/output error occurs
    `javax.servlet.ServletException` - if a servlet-specified error occurs

### doHead

    protected void doHead(javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response)
                   throws java.io.IOException,
                          javax.servlet.ServletException

  Process a HEAD request for the specified resource.

  Parameters:
    `request` - The servlet request we are processing
    `response` - The servlet response we are creating
  Throws:
    `java.io.IOException` - if an input/output error occurs
    `javax.servlet.ServletException` - if a servlet-specified error occurs

### doPost

    protected void doPost(javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response)
                   throws java.io.IOException,
                          javax.servlet.ServletException

  Process a POST request for the specified resource.

  Parameters:
    `request` - The servlet request we are processing
    `response` - The servlet response we are creating
  Throws:
    `java.io.IOException` - if an input/output error occurs
    `javax.servlet.ServletException` - if a servlet-specified error occurs

### doPut

    protected void doPut(javax.servlet.http.HttpServletRequest req,
                         javax.servlet.http.HttpServletResponse resp)
                  throws javax.servlet.ServletException,
                         java.io.IOException

  Process a POST request for the specified resource.

  Throws:
    `java.io.IOException` - if an input/output error occurs
    `javax.servlet.ServletException` - if a servlet-specified error occurs

### executePartialPut

    protected java.io.File executePartialPut(javax.servlet.http.HttpServletRequest req,
                                             org.apache.catalina.servlets.DefaultServlet.Range range,
                                             java.lang.String path)
                                      throws java.io.IOException

  Handle a partial PUT. New content specified in request is appended to existing content in oldRevisionContent (if present). This code does not support simultaneous partial updates to the same resource.

  Throws:
    `java.io.IOException`

### doDelete

    protected void doDelete(javax.servlet.http.HttpServletRequest req,
                            javax.servlet.http.HttpServletResponse resp)
                     throws javax.servlet.ServletException,
                            java.io.IOException

  Process a POST request for the specified resource.

  Throws:
    `java.io.IOException` - if an input/output error occurs
    `javax.servlet.ServletException` - if a servlet-specified error occurs

### checkIfHeaders

    protected boolean checkIfHeaders(javax.servlet.http.HttpServletRequest request,
                                     javax.servlet.http.HttpServletResponse response,
                                     DefaultServlet.ResourceInfo resourceInfo)
                              throws java.io.IOException

  Check if the conditions specified in the optional If headers are satisfied.

  Parameters:
    `request` - The servlet request we are processing
    `response` - The servlet response we are creating
    `resourceInfo` - File object
  Returns:
    boolean true if the resource meets all the specified conditions, and false if any of the conditions is not satisfied, in which case request processing is stopped
  Throws:
    `java.io.IOException`

### getETag

    protected java.lang.String getETag(DefaultServlet.ResourceInfo resourceInfo)

  Get the ETag associated with a file.

  Parameters:
    `resourceInfo` - File object

### normalize

    protected java.lang.String normalize(java.lang.String path)

  Return a context-relative path, beginning with a "/", that represents the canonical version of the specified path after ".." and "." elements are resolved out. If the specified path attempts to go outside the boundaries of the current context (i.e. too many ".." path elements are present), return `null` instead.

  Parameters:
    `path` - Path to be normalized

### rewriteUrl

    protected java.lang.String rewriteUrl(java.lang.String path)

  URL rewriter.

  Parameters:
    `path` - Path which has to be rewiten

### displaySize

    protected void displaySize(java.lang.StringBuffer buf,
                               int filesize)

  Display the size of a file.

### serveResource

    protected void serveResource(javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response,
                                 boolean content)
                          throws java.io.IOException,
                                 javax.servlet.ServletException

  Serve the specified resource, optionally including the data content.

  Parameters:
    `request` - The servlet request we are processing
    `response` - The servlet response we are creating
    `content` - Should the content be included?
  Throws:
    `java.io.IOException` - if an input/output error occurs
    `javax.servlet.ServletException` - if a servlet-specified error occurs

### parseContentRange

    protected org.apache.catalina.servlets.DefaultServlet.Range parseContentRange(javax.servlet.http.HttpServletRequest request,
                                                                                  javax.servlet.http.HttpServletResponse response)
                                                                           throws java.io.IOException

  Parse the content-range header.

  Parameters:
    `request` - The servlet request we are processing
    `response` - The servlet response we are creating
  Returns:
    Range
  Throws:
    `java.io.IOException`

### parseRange

    protected java.util.Vector parseRange(javax.servlet.http.HttpServletRequest request,
                                          javax.servlet.http.HttpServletResponse response,
                                          DefaultServlet.ResourceInfo resourceInfo)
                                   throws java.io.IOException

  Parse the range header.

  Parameters:
    `request` - The servlet request we are processing
    `response` - The servlet response we are creating
  Returns:
    Vector of ranges
  Throws:
    `java.io.IOException`

### appendParameters

    protected java.lang.String appendParameters(javax.servlet.http.HttpServletRequest request,
                                                java.lang.String redirectPath)

  Append the request parameters to the redirection string before calling sendRedirect.

### render

    protected java.io.InputStream render(java.lang.String contextPath,
                                         DefaultServlet.ResourceInfo resourceInfo)

  Return an InputStream to an HTML representation of the contents of this directory.

  Parameters:
    `contextPath` - Context path to which our internal paths are relative

### renderSize

    protected java.lang.String renderSize(long size)

  Render the specified file size (in bytes).

  Parameters:
    `size` - File size (in bytes)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2002 Apache Software Foundation. All Rights Reserved.