Top Description Fields Constructors Methods
org.mortbay.jetty.handler

public Class ResourceHandler

extends AbstractHandler
Class Inheritance
Imports
java.io.IOException, .OutputStream, java.net.MalformedURLException, javax.servlet.ServletException, javax.servlet.http.HttpServletRequest, .HttpServletResponse, org.mortbay.io.Buffer, .ByteArrayBuffer, .WriterOutputStream, org.mortbay.jetty.HttpConnection, .HttpFields, .HttpHeaders, .HttpMethods, .MimeTypes, .Request, .Response, org.mortbay.jetty.handler.ContextHandler.SContext, org.mortbay.log.Log, org.mortbay.resource.Resource, org.mortbay.util.TypeUtil, .URIUtil

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)

Field Summary

Modifier and TypeField and Description
pack-priv Resource
pack-priv ByteArrayBuffer
pack-priv ContextHandler
pack-priv MimeTypes
pack-priv String[]
Inherited from org.mortbay.jetty.handler.AbstractHandler:
_string

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
doResponseHeaders(HttpServletResponse response, Resource resource, String mimeType)

Set the response headers.

public void
public Resource

Returns:

Returns the resourceBase.
getBaseResource
()

public String

Returns:

the cacheControl header to set on all static content.
getCacheControl
()

public MimeTypes
public Resource
protected Resource
public String

Returns:

Returns the base resource as a string.
getResourceBase
()

protected Resource
getWelcome(Resource directory)

public String[]
public void
handle(String
The target of the request - either a URI or a name.
target
,
HttpServletRequest
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.
request
,
HttpServletResponse
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.
response
,
int
The dispatch mode: REQUEST, FORWARD, INCLUDE, ERROR
dispatch
)

Implements org.mortbay.jetty.Handler.handle.

Handle a request.
public void
setBaseResource(Resource
The resourceBase to set.
base
)

public void
setCacheControl(String
the cacheControl header to set on all static content.
cacheControl
)

public void
public void
setResourceBase(String
The base resource as a string.
resourceBase
)

public void
setWelcomeFiles(String[] welcomeFiles)

Inherited from org.mortbay.jetty.handler.AbstractHandler:
destroydoStopgetServersetServertoString

Field Detail

_baseResourceback to summary
pack-priv Resource _baseResource
_cacheControlback to summary
pack-priv ByteArrayBuffer _cacheControl
_contextback to summary
pack-priv ContextHandler _context
_mimeTypesback to summary
pack-priv MimeTypes _mimeTypes
_welcomeFilesback to summary
pack-priv String[] _welcomeFiles

Constructor Detail

ResourceHandlerback to summary
public ResourceHandler()

Method Detail

doResponseHeadersback to summary
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.

doStartback to summary
public void doStart() throws Exception

Overrides org.mortbay.jetty.handler.AbstractHandler.doStart.

getBaseResourceback to summary
public Resource getBaseResource()
Returns:Resource

Returns the resourceBase.

getCacheControlback to summary
public String getCacheControl()
Returns:String

the cacheControl header to set on all static content.

getMimeTypesback to summary
public MimeTypes getMimeTypes()
getResourceback to summary
public Resource getResource(String path) throws MalformedURLException
getResourceback to summary
protected Resource getResource(HttpServletRequest request) throws MalformedURLException
getResourceBaseback to summary
public String getResourceBase()
Returns:String

Returns the base resource as a string.

getWelcomeback to summary
protected Resource getWelcome(Resource directory) throws MalformedURLException, IOException
getWelcomeFilesback to summary
public String[] getWelcomeFiles()
handleback to summary
public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException

Implements org.mortbay.jetty.Handler.handle.

Doc from org.mortbay.jetty.Handler.handle.

Handle a request.

Parameters
target:String

The target of the request - either a URI or a name.

request:HttpServletRequest

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:HttpServletResponse

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:int

The dispatch mode: REQUEST, FORWARD, INCLUDE, ERROR

setBaseResourceback to summary
public void setBaseResource(Resource base)
Parameters
base:Resource

The resourceBase to set.

setCacheControlback to summary
public void setCacheControl(String cacheControl)
Parameters
cacheControl:String

the cacheControl header to set on all static content.

setMimeTypesback to summary
public void setMimeTypes(MimeTypes mimeTypes)
setResourceBaseback to summary
public void setResourceBase(String resourceBase)
Parameters
resourceBase:String

The base resource as a string.

setWelcomeFilesback to summary
public void setWelcomeFiles(String[] welcomeFiles)