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.39.2.7 $ $Date: 2002/10/08 07:56:04 $
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 static java.text.SimpleDateFormat[]` | `formats` The set of SimpleDateFormat formats to use in getDateHeader().
`protected static java.util.TimeZone` | `gmtZone`
`protected static char[]` | `hexadecimal`
`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 java.util.BitSet` | `safeCharacters` Array containing the safe characters set.
`protected static StringManager` | `sm` The string manager for this package.
`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.lang.String` | `getETag(DefaultServlet.ResourceInfo resourceInfo, boolean strong)` Get the ETag associated with a file.
`protected java.lang.String` | `getETagValue(DefaultServlet.ResourceInfo resourceInfo, boolean strong)` Get the ETag value 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 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` | `renderLastModified(long lastModified)` Render the last modified date and time for the specified timestamp.
`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.

### 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

### 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.

### safeCharacters

    protected static java.util.BitSet safeCharacters

  Array containing the safe characters set.

### hexadecimal

    protected static final char[] hexadecimal

Constructor Detail

### DefaultServlet

    public DefaultServlet()

Method Detail

### destroy

    public void destroy()

  Finalize this servlet.

  Specified by:
    `destroy` in interface `javax.servlet.Servlet`
  Overrides:
    `destroy` in class `javax.servlet.GenericServlet`

### init

    public void init()
              throws javax.servlet.ServletException

  Initialize this servlet.

  Overrides:
    `init` in class `javax.servlet.GenericServlet`
    `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.

  Overrides:
    `doGet` in class `javax.servlet.http.HttpServlet`
  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.

  Overrides:
    `doHead` in class `javax.servlet.http.HttpServlet`
  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.

  Overrides:
    `doPost` in class `javax.servlet.http.HttpServlet`
  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.

  Overrides:
    `doPut` in class `javax.servlet.http.HttpServlet`
  Throws:
    `java.io.IOException` - if an input/output error occurs
    `javax.servlet.ServletException` - if a servlet-specified error occurs

### 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.

  Overrides:
    `doDelete` in class `javax.servlet.http.HttpServlet`
  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
    `java.io.IOException`

### getETagValue

    protected java.lang.String getETagValue(DefaultServlet.ResourceInfo resourceInfo,
                                            boolean strong)

  Get the ETag value associated with a file.

  Parameters:
    `resourceInfo` - File object
    `strong` - True if we want a strong ETag, in which case a checksum of the file has to be calculated

### getETag

    protected java.lang.String getETag(DefaultServlet.ResourceInfo resourceInfo,
                                       boolean strong)

  Get the ETag associated with a file.

  Parameters:
    `resourceInfo` - File object
    `strong` - True if we want a strong ETag, in which case a checksum of the file has to be calculated

### 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

### 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
    `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

### renderLastModified

    protected java.lang.String renderLastModified(long lastModified)

  Render the last modified date and time for the specified timestamp.

  Parameters:
    `lastModified` - Last modified date and time, in milliseconds since the epoch

### 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-2001 Apache Software Foundation. All Rights Reserved.