Top Description Fields Constructors Methods
org.glassfish.grizzly.http.server

public Class StaticHttpHandler

extends StaticHttpHandlerBase
Class Inheritance
Imports
java.io.File, java.util.Set, java.util.logging.Level, .Logger, org.glassfish.grizzly.Grizzly, org.glassfish.grizzly.http.Method, org.glassfish.grizzly.http.util.Header, .HttpStatus, org.glassfish.grizzly.utils.ArraySet

HttpHandler, which processes requests to a static resources.
Authors
Jeanfrancois Arcand, Alexey Stashok

Field Summary

Modifier and TypeField and Description
private boolean
protected final ArraySet<File>
private static final Logger

Constructor Summary

AccessConstructor and Description
public
StaticHttpHandler()

Create HttpHandler, which, by default, will handle requests to the static resources located in the current directory.

public
StaticHttpHandler(String...
the folder(s) where the static resource are located. If the docRoot is null - static pages won't be served by this HttpHandler
docRoots
)

Create a new instance which will look for static pages located under the docRoot.

public
StaticHttpHandler(Set<String>
the folders where the static resource are located. If the docRoot is empty - static pages won't be served by this HttpHandler
docRoots
)

Create a new instance which will look for static pages located under the docRoot.

Method Summary

Modifier and TypeMethod and Description
public final File

Returns:

return the File representation of the passed docRoot.
addDocRoot
(String
the directory to be added to the list of directories where files will be serviced from.
docRoot
)

Add the directory to the list of directories where files will be serviced from.

public final void
addDocRoot(File
the directory to be added to the list of directories where files will be serviced from.
docRoot
)

Add the directory to the list of directories where files will be serviced from.

public File

Returns:

the default directory from where file will be serviced.
getDefaultDocRoot
()

Return the default directory from where files will be serviced.

public ArraySet<File>

Returns:

the list of directories where files will be serviced from.
getDocRoots
()

Return the list of directories where files will be serviced from.

protected boolean
handle(final String uri, final Request request, final Response response)

Implements abstract org.glassfish.grizzly.http.server.StaticHttpHandlerBase.handle.

Lookup a resource based on the request URI, and process it.

public boolean
isDirectorySlashOff()

Returns: true if HTTP 301 redirect shouldn't be sent when requested static resource is a directory, or false otherwise

public void
removeDocRoot(File
the directory to remove.
docRoot
)

Removes the directory from the list of directories where static files will be serviced from.

public void
setDirectorySlashOff(boolean directorySlashOff)

If the directorySlashOff is true HTTP 301 redirect will not be sent when requested static resource is a directory.

Inherited from org.glassfish.grizzly.http.server.StaticHttpHandlerBase:
addCachingHeadersaddToFileCachegetRelativeURIisFileCacheEnabledlookupFileCacheonMissingResourcepickupContentTypesendFileservicesetFileCacheEnabled

Field Detail

directorySlashOffback to summary
private boolean directorySlashOff
docRootsback to summary
protected final ArraySet<File> docRoots
LOGGERback to summary
private static final Logger LOGGER

Hides org.glassfish.grizzly.http.server.StaticHttpHandlerBase.LOGGER.

Constructor Detail

StaticHttpHandlerback to summary
public StaticHttpHandler()

Create HttpHandler, which, by default, will handle requests to the static resources located in the current directory.

StaticHttpHandlerback to summary
public StaticHttpHandler(String... docRoots)

Create a new instance which will look for static pages located under the docRoot. If the docRoot is null - static pages won't be served by this HttpHandler

Parameters
docRoots:String[]

the folder(s) where the static resource are located. If the docRoot is null - static pages won't be served by this HttpHandler

StaticHttpHandlerback to summary
public StaticHttpHandler(Set<String> docRoots)

Create a new instance which will look for static pages located under the docRoot. If the docRoot is null - static pages won't be served by this HttpHandler

Parameters
docRoots:Set<String>

the folders where the static resource are located. If the docRoot is empty - static pages won't be served by this HttpHandler

Annotations
@SuppressWarnings:UnusedDeclaration

Method Detail

addDocRootback to summary
public final File addDocRoot(String docRoot)

Add the directory to the list of directories where files will be serviced from.

Parameters
docRoot:String

the directory to be added to the list of directories where files will be serviced from.

Returns:File

return the File representation of the passed docRoot.

addDocRootback to summary
public final void addDocRoot(File docRoot)

Add the directory to the list of directories where files will be serviced from.

Parameters
docRoot:File

the directory to be added to the list of directories where files will be serviced from.

getDefaultDocRootback to summary
public File getDefaultDocRoot()

Return the default directory from where files will be serviced.

Returns:File

the default directory from where file will be serviced.

Annotations
@SuppressWarnings:UnusedDeclaration
getDocRootsback to summary
public ArraySet<File> getDocRoots()

Return the list of directories where files will be serviced from.

Returns:ArraySet<File>

the list of directories where files will be serviced from.

handleback to summary
protected boolean handle(final String uri, final Request request, final Response response) throws Exception

Implements abstract org.glassfish.grizzly.http.server.StaticHttpHandlerBase.handle.

Doc from org.glassfish.grizzly.http.server.StaticHttpHandlerBase.handle.

Lookup a resource based on the request URI, and process it.

Annotations
@Override
isDirectorySlashOffback to summary
public boolean isDirectorySlashOff()
Returns:boolean

true if HTTP 301 redirect shouldn't be sent when requested static resource is a directory, or false otherwise

removeDocRootback to summary
public void removeDocRoot(File docRoot)

Removes the directory from the list of directories where static files will be serviced from.

Parameters
docRoot:File

the directory to remove.

Annotations
@SuppressWarnings:UnusedDeclaration
setDirectorySlashOffback to summary
public void setDirectorySlashOff(boolean directorySlashOff)

If the directorySlashOff is true HTTP 301 redirect will not be sent when requested static resource is a directory.