com.mortbay.HTTP.Handler
Class FileHandler

java.lang.Object
  |
  +--com.mortbay.HTTP.Handler.NullHandler
        |
        +--com.mortbay.HTTP.Handler.FileHandler

public class FileHandler
extends NullHandler

FileHandler This handler attempts to match files to a file or directory and return a response set by the MIME type indicated by the file extension. The request path is used as a filepath relative to the configured fileBase.

Version:
$Id: FileHandler.java,v 2.28 2000/08/14 14:18:40 gregwilkins Exp $
Author:
Greg Wilkins
See Also:
Interface.HttpHandler

Fields inherited from class com.mortbay.HTTP.Handler.NullHandler
httpServer
 
Constructor Summary
FileHandler(PathMap directoryMap)
          Construct a FileHandler
FileHandler(java.util.Properties properties)
          Construct from properties.
FileHandler(java.lang.String fileBase)
          Construct a FileHandler at "/" for the given fileBase
FileHandler(java.lang.String fileBase, java.lang.String indexFile)
          Construct a FileHandler at the given fileBase and use indexFile as the default directory return file.
 
Method Summary
 void handle(HttpRequest request, HttpResponse response)
          Constructor
 boolean isDeleteAllowed()
           
 boolean isDirAllowed()
           
 boolean isPutAllowed()
           
 void setDeleteAllowed(boolean deleteAllowed_)
           
 void setDirAllowed(boolean dirAllowed_)
           
 void setProperties(java.util.Properties properties)
          Configure from Properties.
 void setPutAllowed(boolean putAllowed_)
           
 java.lang.String translate(java.lang.String path)
          Translate a path string.
 
Methods inherited from class com.mortbay.HTTP.Handler.NullHandler
destroy, getProperties, servlet, servletNames, setServer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileHandler

public FileHandler(java.util.Properties properties)
            throws java.io.IOException
Construct from properties.
Parameters:
properties - Passed to setProperties

FileHandler

public FileHandler(java.lang.String fileBase)
Construct a FileHandler at "/" for the given fileBase

FileHandler

public FileHandler(java.lang.String fileBase,
                   java.lang.String indexFile)
Construct a FileHandler at the given fileBase and use indexFile as the default directory return file.

FileHandler

public FileHandler(PathMap directoryMap)
Construct a FileHandler
Parameters:
directoryMap - PathMap of pathname to directory name
Method Detail

setProperties

public void setProperties(java.util.Properties properties)
                   throws java.io.IOException
Configure from Properties. Properties are assumed to be in the format of a PropertyTree like:
 Indexes              : index.html,index.htm
 AllowPut             : False
 AllowDelete          : False
 AllowDir             : True
 MaxCachedFiles       : 100
 MaxCachedFileSize    : 8192
 FILES.name.PATHS     : /pathSpec;/list%
 FILES.name.DIRECTORY : /Directory
Overrides:
setProperties in class NullHandler
Parameters:
properties - Configuration.

isPutAllowed

public boolean isPutAllowed()

setPutAllowed

public void setPutAllowed(boolean putAllowed_)

isDeleteAllowed

public boolean isDeleteAllowed()

setDeleteAllowed

public void setDeleteAllowed(boolean deleteAllowed_)

isDirAllowed

public boolean isDirAllowed()

setDirAllowed

public void setDirAllowed(boolean dirAllowed_)

translate

public java.lang.String translate(java.lang.String path)
Description copied from interface: HttpHandler
Translate a path string. Used by getRealPath method.
Overrides:
translate in class NullHandler
Tags copied from interface: HttpHandler
Returns:
the translated path

handle

public void handle(HttpRequest request,
                   HttpResponse response)
            throws java.lang.Exception
Description copied from interface: HttpHandler
Constructor
Overrides:
handle in class NullHandler
Tags copied from interface: HttpHandler
Parameters:
request - The HTTP requests to be handled
response - The HTTP response to be used.