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:
- org.mortbay.component.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 classes/interfaces inherited from interface org.mortbay.component.LifeCycle |
org.mortbay.component.LifeCycle.Listener |
Fields inherited from class org.mortbay.component.AbstractLifeCycle |
_listeners |
Methods inherited from class org.mortbay.component.AbstractLifeCycle |
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop |
Methods inherited from interface org.mortbay.component.LifeCycle |
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop |
ResourceHandler
public ResourceHandler()
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 Exception
- Overrides:
doStart
in class AbstractHandler
- Throws:
Exception
getBaseResource
public Resource getBaseResource()
- Returns:
- Returns the resourceBase.
getResourceBase
public 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(String resourceBase)
- Parameters:
resourceBase
- The base resource as a string.
getCacheControl
public String getCacheControl()
- Returns:
- the cacheControl header to set on all static content.
setCacheControl
public void setCacheControl(String cacheControl)
- Parameters:
cacheControl
- the cacheControl header to set on all static content.
getResource
public Resource getResource(String path)
throws MalformedURLException
- Throws:
MalformedURLException
getResource
protected Resource getResource(HttpServletRequest request)
throws MalformedURLException
- Throws:
MalformedURLException
getWelcomeFiles
public String[] getWelcomeFiles()
setWelcomeFiles
public void setWelcomeFiles(String[] welcomeFiles)
getWelcome
protected Resource getWelcome(Resource directory)
throws MalformedURLException,
IOException
- Throws:
MalformedURLException
IOException
handle
public void handle(String target,
HttpServletRequest request,
HttpServletResponse response,
int dispatch)
throws IOException,
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:
IOException
ServletException
doResponseHeaders
protected void doResponseHeaders(HttpServletResponse response,
Resource resource,
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
-
Copyright © 2009 Mortbay Consulting Pty. Ltd. All Rights Reserved.