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

## org.mortbay.jetty.handler
Class ResourceHandler

    java.lang.Object
      org.mortbay.component.AbstractLifeCycle
          org.mortbay.jetty.handler.AbstractHandler
              org.mortbay.jetty.handler.ResourceHandler

All Implemented Interfaces:
  LifeCycle, Handler

    public class ResourceHandler

extends AbstractHandler

Resource Handler. This handle will serve static content and handle If-Modified-Since headers. No caching is done. Requests that cannot be handled are let pass (Eg no 404's)

Author:
  Greg Wilkins (gregw)

Nested Class Summary

Nested classes/interfaces inherited from interface org.mortbay.component.LifeCycle
`LifeCycle.Listener`

Field Summary

Fields inherited from class org.mortbay.jetty.handler.AbstractHandler
`_string`

Fields inherited from class org.mortbay.component.AbstractLifeCycle
`_listeners`

Fields inherited from interface org.mortbay.jetty.Handler
`ALL, DEFAULT, ERROR, FORWARD, INCLUDE, REQUEST`

Constructor Summary
`ResourceHandler()`

Method Summary
`protected void` | `doResponseHeaders(javax.servlet.http.HttpServletResponse response, Resource resource, java.lang.String mimeType)` Set the response headers.
`void` | `doStart()`
`Resource` | `getBaseResource()`
`java.lang.String` | `getCacheControl()`
`MimeTypes` | `getMimeTypes()`
`protected Resource` | `getResource(javax.servlet.http.HttpServletRequest request)`
`Resource` | `getResource(java.lang.String path)`
`java.lang.String` | `getResourceBase()`
`protected Resource` | `getWelcome(Resource directory)`
`java.lang.String[]` | `getWelcomeFiles()`
`void` | `handle(java.lang.String target, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, int dispatch)` Handle a request.
`boolean` | `isAliases()`
`void` | `setAliases(boolean aliases)` Set if resource aliases (eg symlink, 8.3 names, case insensitivity) are allowed.
`void` | `setBaseResource(Resource base)`
`void` | `setCacheControl(java.lang.String cacheControl)`
`void` | `setMimeTypes(MimeTypes mimeTypes)`
`void` | `setResourceBase(java.lang.String resourceBase)`
`void` | `setWelcomeFiles(java.lang.String[] welcomeFiles)`

Methods inherited from class org.mortbay.jetty.handler.AbstractHandler
`destroy, doStop, getServer, setServer, toString`

Methods inherited from class org.mortbay.component.AbstractLifeCycle
`addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

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

Methods inherited from interface org.mortbay.component.LifeCycle
`addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

Constructor Detail

### ResourceHandler

    public ResourceHandler()

Method Detail

### getMimeTypes

    public MimeTypes getMimeTypes()

### setMimeTypes

    public void setMimeTypes(MimeTypes mimeTypes)

### isAliases

    public boolean isAliases()

  Returns:
    True if resource aliases are allowed.

### setAliases

    public void setAliases(boolean aliases)

  Set if resource aliases (eg symlink, 8.3 names, case insensitivity) are allowed. Allowing aliases can significantly increase security vulnerabilities.

  Parameters:
    `aliases` - True if aliases are supported.

### doStart

    public void doStart()
                 throws java.lang.Exception

  Overrides:
    `doStart` in class `AbstractHandler`
  Throws:
    `java.lang.Exception`

### getBaseResource

    public Resource getBaseResource()

  Returns:
    Returns the resourceBase.

### getResourceBase

    public java.lang.String getResourceBase()

  Returns:
    Returns the base resource as a string.

### setBaseResource

    public void setBaseResource(Resource base)

  Parameters:
    `base` - The resourceBase to set.

### setResourceBase

    public void setResourceBase(java.lang.String resourceBase)

  Parameters:
    `resourceBase` - The base resource as a string.

### getCacheControl

    public java.lang.String getCacheControl()

  Returns:
    the cacheControl header to set on all static content.

### setCacheControl

    public void setCacheControl(java.lang.String cacheControl)

  Parameters:
    `cacheControl` - the cacheControl header to set on all static content.

### getResource

    public Resource getResource(java.lang.String path)
                         throws java.net.MalformedURLException

  Throws:
    `java.net.MalformedURLException`

### getResource

    protected Resource getResource(javax.servlet.http.HttpServletRequest request)
                            throws java.net.MalformedURLException

  Throws:
    `java.net.MalformedURLException`

### getWelcomeFiles

    public java.lang.String[] getWelcomeFiles()

### setWelcomeFiles

    public void setWelcomeFiles(java.lang.String[] welcomeFiles)

### getWelcome

    protected Resource getWelcome(Resource directory)
                           throws java.net.MalformedURLException,
                                  java.io.IOException

  Throws:
    `java.net.MalformedURLException`
    `java.io.IOException`

### handle

    public void handle(java.lang.String target,
                       javax.servlet.http.HttpServletRequest request,
                       javax.servlet.http.HttpServletResponse response,
                       int dispatch)
                throws java.io.IOException,
                       javax.servlet.ServletException

  Description copied from interface: `Handler`
  Handle a request.

  Parameters:
    `target` - The target of the request - either a URI or a name.
    `request` - The request either as the `Request` object or a wrapper of that request. The `HttpConnection.getCurrentConnection()` method can be used access the Request object if required.
    `response` - The response as the `Response` object or a wrapper of that request. The `HttpConnection.getCurrentConnection()` method can be used access the Response object if required.
    `dispatch` - The dispatch mode: `Handler.REQUEST`, `Handler.FORWARD`, `Handler.INCLUDE`, `Handler.ERROR`
  Throws:
    `java.io.IOException`
    `javax.servlet.ServletException`

### doResponseHeaders

    protected void doResponseHeaders(javax.servlet.http.HttpServletResponse response,
                                     Resource resource,
                                     java.lang.String mimeType)

  Set the response headers. This method is called to set the response headers such as content type and content length. May be extended to add additional headers.

  Parameters:
    `response` -
    `resource` -
    `mimeType` -

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

Copyright © 1995-2010 Mort Bay Consulting. All Rights Reserved.