Class StaticHttpHandler
java.lang.Object
org.glassfish.grizzly.http.server.HttpHandler
org.glassfish.grizzly.http.server.StaticHttpHandlerBase
org.glassfish.grizzly.http.server.StaticHttpHandler
HttpHandler, which processes requests to a static resources.- Author:
- Jeanfrancois Arcand, Alexey Stashok
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate HttpHandler, which, by default, will handle requests to the static resources located in the current directory.StaticHttpHandler(String... docRoots) Create a new instance which will look for static pages located under the docRoot.StaticHttpHandler(Set<String> docRoots) Create a new instance which will look for static pages located under the docRoot. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddDocRoot(File docRoot) Add the directory to the list of directories where files will be serviced from.final FileaddDocRoot(String docRoot) Add the directory to the list of directories where files will be serviced from.Return the default directory from where files will be serviced.org.glassfish.grizzly.utils.ArraySet<File>Return the list of directories where files will be serviced from.protected booleanLookup a resource based on the request URI, and process it.booleanvoidremoveDocRoot(File docRoot) Removes the directory from the list of directories where static files will be serviced from.voidsetDirectorySlashOff(boolean directorySlashOff) If the directorySlashOff is true HTTP 301 redirect will not be sent when requested static resource is a directory.Methods inherited from class org.glassfish.grizzly.http.server.StaticHttpHandlerBase
addCachingHeaders, addToFileCache, getRelativeURI, isFileCacheEnabled, lookupFileCache, onMissingResource, pickupContentType, sendFile, service, setFileCacheEnabledMethods inherited from class org.glassfish.grizzly.http.server.HttpHandler
destroy, getErrorPageGenerator, getName, getRequestExecutorProvider, getRequestURIEncoding, getSessionCookieName, getSessionManager, isAllowCustomStatusMessage, isAllowEncodedSlash, sendAcknowledgment, setAllowCustomStatusMessage, setAllowEncodedSlash, setDecodeUrl, setDispatcherHelper, setRequestURIEncoding, setRequestURIEncoding, start, updatePaths
-
Field Details
-
docRoots
-
-
Constructor Details
-
StaticHttpHandler
public StaticHttpHandler()Create HttpHandler, which, by default, will handle requests to the static resources located in the current directory. -
StaticHttpHandler
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- the folder(s) where the static resource are located. If the docRoot is null - static pages won't be served by this HttpHandler
-
StaticHttpHandler
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- the folders where the static resource are located. If the docRoot is empty - static pages won't be served by this HttpHandler
-
-
Method Details
-
getDefaultDocRoot
Return the default directory from where files will be serviced.- Returns:
- the default directory from where file will be serviced.
-
getDocRoots
Return the list of directories where files will be serviced from.- Returns:
- the list of directories where files will be serviced from.
-
addDocRoot
Add the directory to the list of directories where files will be serviced from.- Parameters:
docRoot- the directory to be added to the list of directories where files will be serviced from.- Returns:
- return the
Filerepresentation of the passeddocRoot.
-
addDocRoot
Add the directory to the list of directories where files will be serviced from.- Parameters:
docRoot- the directory to be added to the list of directories where files will be serviced from.
-
removeDocRoot
Removes the directory from the list of directories where static files will be serviced from.- Parameters:
docRoot- the directory to remove.
-
isDirectorySlashOff
public boolean isDirectorySlashOff()- Returns:
- true if HTTP 301 redirect shouldn't be sent when requested static resource is a directory, or false otherwise
-
setDirectorySlashOff
public void setDirectorySlashOff(boolean directorySlashOff) If the directorySlashOff is true HTTP 301 redirect will not be sent when requested static resource is a directory.- Parameters:
directorySlashOff-
-
handle
Lookup a resource based on the request URI, and process it.- Specified by:
handlein classStaticHttpHandlerBase- Parameters:
uri- The request URIrequest- theRequestresponse- theResponse- Returns:
- true, if the static resource has been found and processed, or false, if the static resource hasn't been found
- Throws:
Exception
-