Class ContextHandler
- All Implemented Interfaces:
Handler
,HandlerContainer
,Attributes
,Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,Graceful
,LifeCycle
- Direct Known Subclasses:
HttpSpiContextHandler
,MovedContextHandler
,ServletContextHandler
This handler wraps a call to handle by setting the context and servlet path, plus setting the context classloader.
If the context init parameter org.eclipse.jetty.server.context.ManagedAttributes
is set to a comma separated list of names, then they are treated as
context attribute names, which if set as attributes are passed to the servers Container so that they may be managed with JMX.
The maximum size of a form that can be processed by this context is controlled by the system properties org.eclipse.jetty.server.Request.maxFormKeys
and
org.eclipse.jetty.server.Request.maxFormContentSize
. These can also be configured with setMaxFormContentSize(int)
and setMaxFormKeys(int)
The executor is made available via a context attributed org.eclipse.jetty.server.Executor
.
By default, the context is created with the AllowedResourceAliasChecker
which is configured to allow symlinks. If
this alias checker is not required, then clearAliasChecks()
or setAliasChecks(List)
should be called.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Interface to check aliasesstatic class
Deprecated.static class
Deprecated.static enum
class
Context.static interface
Listener for all threads entering context scope, including async IO callbacksstatic enum
static class
A simple implementation of ServletContext that is used when there is no ContextHandler.Nested classes/interfaces inherited from class org.eclipse.jetty.server.handler.AbstractHandler
AbstractHandler.ErrorDispatchHandler
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopException
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.Attributes
Attributes.Wrapper
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Graceful
Graceful.Shutdown, Graceful.ThrowingRunnable
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
Field Summary
Modifier and TypeFieldDescriptionprotected ContextHandler.ContextStatus
protected ContextHandler.Context
static final int
static final int
static final int
static final int
static final String
static final String
static final String
static final Class<?>[]
static final int
static final int
Fields inherited from class org.eclipse.jetty.server.handler.ScopedHandler
_nextScope, _outerScope
Fields inherited from class org.eclipse.jetty.server.handler.HandlerWrapper
_handler
-
Constructor Summary
ModifierConstructorDescriptionContextHandler
(String contextPath) protected
ContextHandler
(ContextHandler.Context context) protected
ContextHandler
(ContextHandler.Context context, HandlerContainer parent, String contextPath) ContextHandler
(HandlerContainer parent, String contextPath) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add an AliasCheck instance to possibly permit aliased resourcesboolean
addEventListener
(EventListener listener) Add a context event listeners.void
addLocaleEncoding
(String locale, String encoding) protected void
addProgrammaticListener
(EventListener listener) Apply any necessary restrictions on a programmatic added listener.void
addVirtualHosts
(String[] virtualHosts) Either set virtual hosts or add to an existing set of virtual hosts.protected void
callContextDestroyed
(javax.servlet.ServletContextListener l, javax.servlet.ServletContextEvent e) protected void
callContextInitialized
(javax.servlet.ServletContextListener l, javax.servlet.ServletContextEvent e) boolean
checkAlias
(String path, Resource resource) boolean
checkContext
(String target, Request baseRequest, javax.servlet.http.HttpServletResponse response) boolean
checkContextPath
(String uri) boolean
checkVirtualHost
(Request baseRequest) void
clear the list of AliasChecksvoid
void
Call the ServletContextListeners with contextDestroyed.void
Call the ServletContextListeners contextInitialized methods.void
doHandle
(String target, Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Do the handler work within the scope.void
doScope
(String target, Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Scope the handlerprotected void
doStart()
Starts the managed lifecycle beans in the order they were added.protected void
doStop()
Stops the managed lifecycle beans in the reverse order they were added.void
dump
(Appendable out, String indent) Dump this object (and children) into an Appendable using the provided indent after any new lines.protected void
enterScope
(Request request, Object reason) protected void
boolean
getAttribute
(String name) Make best effort to extract a file classpath from the context classloaderstatic ContextHandler
getContextHandler
(javax.servlet.ServletContext context) static ContextHandler.Context
Get the current ServletContext implementation.getInitParameter
(String name) getLocaleEncoding
(String locale) getLocaleEncoding
(Locale locale) Get the character encoding for a locale.Get all of the locale encodingsorg.slf4j.Logger
int
int
String[]
Get the context path in a form suitable to be returned fromHttpServletRequest.getContextPath()
orServletContext.getContextPath()
.getResource
(String pathInContext) Attempt to get a Resource from the Context.getResourcePaths
(String path) static String
String[]
Get the virtual hosts for the context.String[]
void
void
Handle a runnable in the scope of this context and a particular requestboolean
boolean
Deprecated.useCompactPathRule
withRewriteHandler
instead.boolean
boolean
isDurableListener
(EventListener listener) boolean
isProgrammaticListener
(EventListener listener) boolean
isProtectedTarget
(String target) Check the target.boolean
boolean
Class<?>
newResource
(String urlOrPath) Convert a URL or path to a Resource.newResource
(URI uri) Convert URL to Resource wrapper forResource.newResource(URL)
enables extensions to provide alternate resource implementations.newResource
(URL url) Convert URL to Resource wrapper forResource.newResource(URL)
enables extensions to provide alternate resource implementations.void
removeAttribute
(String name) boolean
removeEventListener
(EventListener listener) Remove an event listener.void
removeVirtualHosts
(String[] virtualHosts) Removes an array of virtual host entries, if this removes all entries the _vhosts will be set to nullprotected void
requestDestroyed
(Request baseRequest, javax.servlet.http.HttpServletRequest request) protected void
requestInitialized
(Request baseRequest, javax.servlet.http.HttpServletRequest request) void
setAliasChecks
(List<ContextHandler.AliasCheck> checks) void
setAllowNullPathInfo
(boolean allowNullPathInfo) void
setAttribute
(String name, Object value) void
setAttributes
(Attributes attributes) void
setAvailable
(boolean available) Set Available status.void
setBaseResource
(Resource base) Set the base resource for this context.void
setClassLoader
(ClassLoader classLoader) void
setCompactPath
(boolean compactPath) Deprecated.void
setContextPath
(String contextPath) void
setDefaultContextPath
(String contextPath) Set the default context path.void
setDefaultRequestCharacterEncoding
(String encoding) void
setDefaultResponseCharacterEncoding
(String encoding) void
setDisplayName
(String servletContextName) void
setErrorHandler
(ErrorHandler errorHandler) setInitParameter
(String name, String value) void
setLogger
(org.slf4j.Logger logger) void
setMaxFormContentSize
(int maxSize) Set the maximum size of a form post, to protect against DOS attacks from large forms.void
setMaxFormKeys
(int max) Set the maximum number of form Keys to protect against DOS attack from crafted hash keys.void
setMimeTypes
(MimeTypes mimeTypes) void
setProtectedTargets
(String[] targets) void
setResourceBase
(String resourceBase) Set the base resource for this context.void
static void
setServerInfo
(String serverInfo) void
setUsingSecurityManager
(boolean usingSecurityManager) void
setVirtualHosts
(String[] vhosts) Set the virtual hosts for the context.void
setWelcomeFiles
(String[] files) shutdown()
Set shutdown status.protected void
Extensible startContext.protected void
toString()
Methods inherited from class org.eclipse.jetty.server.handler.ScopedHandler
handle, nextHandle, nextScope
Methods inherited from class org.eclipse.jetty.server.handler.HandlerWrapper
destroy, expandChildren, getHandler, getHandlers, insertHandler, setHandler
Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandlerContainer
expandHandler, findContainerOf, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass
Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandler
doError, getServer
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addManaged, contains, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeans
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.util.component.Container
getCachedBeans, getEventListeners
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, start, stop
-
Field Details
-
SERVLET_MAJOR_VERSION
public static final int SERVLET_MAJOR_VERSION- See Also:
-
SERVLET_MINOR_VERSION
public static final int SERVLET_MINOR_VERSION- See Also:
-
SERVLET_LISTENER_TYPES
-
DEFAULT_LISTENER_TYPE_INDEX
public static final int DEFAULT_LISTENER_TYPE_INDEX- See Also:
-
EXTENDED_LISTENER_TYPE_INDEX
public static final int EXTENDED_LISTENER_TYPE_INDEX- See Also:
-
MANAGED_ATTRIBUTES
- See Also:
-
MAX_FORM_KEYS_KEY
- See Also:
-
MAX_FORM_CONTENT_SIZE_KEY
- See Also:
-
DEFAULT_MAX_FORM_KEYS
public static final int DEFAULT_MAX_FORM_KEYS- See Also:
-
DEFAULT_MAX_FORM_CONTENT_SIZE
public static final int DEFAULT_MAX_FORM_CONTENT_SIZE- See Also:
-
_contextStatus
-
_scontext
-
-
Constructor Details
-
ContextHandler
public ContextHandler() -
ContextHandler
-
ContextHandler
-
ContextHandler
-
ContextHandler
protected ContextHandler(ContextHandler.Context context, HandlerContainer parent, String contextPath)
-
-
Method Details
-
getCurrentContext
Get the current ServletContext implementation.- Returns:
- ServletContext implementation
-
getContextHandler
-
getServerInfo
-
setServerInfo
-
dump
Description copied from interface:Dumpable
Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.- Specified by:
dump
in interfaceDumpable
- Overrides:
dump
in classContainerLifeCycle
- Parameters:
out
- The appendable to dump toindent
- The indent to apply after any new lines.- Throws:
IOException
- if unable to write to Appendable
-
getServletContext
-
getAllowNullPathInfo
@ManagedAttribute("Checks if the /context is not redirected to /context/") public boolean getAllowNullPathInfo()- Returns:
- the allowNullPathInfo true if /context is not redirected to /context/
-
setAllowNullPathInfo
public void setAllowNullPathInfo(boolean allowNullPathInfo) - Parameters:
allowNullPathInfo
- true if /context is not redirected to /context/
-
setServer
- Specified by:
setServer
in interfaceHandler
- Overrides:
setServer
in classAbstractHandlerContainer
-
isUsingSecurityManager
public boolean isUsingSecurityManager() -
setUsingSecurityManager
public void setUsingSecurityManager(boolean usingSecurityManager) -
setVirtualHosts
Set the virtual hosts for the context. Only requests that have a matching host header or fully qualified URL will be passed to that context with a virtual host name. A context with no virtual host names or a null virtual host name is available to all requests that are not served by a context with a matching virtual host name.- Parameters:
vhosts
- Array of virtual hosts that this context responds to. A null/empty array means any hostname is acceptable. Host names may be String representation of IP addresses. Host names may start with '*.' to wildcard one level of names. Hosts and wildcard hosts may be followed with '@connectorname', in which case they will match only if the theConnector.getName()
for the request also matches. If an entry is just '@connectorname' it will match any host if that connector was used. Note - In previous versions if one or more connectorname only entries existed and non of the connectors matched the handler would not match regardless of any hostname entries. If there is one or more connectorname only entries and one or more host only entries but no hostname and connector entries we assume the old behavior and will log a warning. The warning can be removed by removing the host entries that were previously being ignored, or modifying to include a hostname and connectorname entry.
-
addVirtualHosts
Either set virtual hosts or add to an existing set of virtual hosts.- Parameters:
virtualHosts
- Array of virtual hosts that this context responds to. A null/empty array means any hostname is acceptable. Host names may be String representation of IP addresses. Host names may start with '*.' to wildcard one level of names. Hosts and wildcard hosts may be followed with '@connectorname', in which case they will match only if the theConnector.getName()
for the request also matches. If an entry is just '@connectorname' it will match any host if that connector was used. Note - In previous versions if one or more connectorname only entries existed and non of the connectors matched the handler would not match regardless of any hostname entries. If there is one or more connectorname only entries and one or more host only entries but no hostname and connector entries we assume the old behavior and will log a warning. The warning can be removed by removing the host entries that were previously being ignored, or modifying to include a hostname and connectorname entry.
-
removeVirtualHosts
Removes an array of virtual host entries, if this removes all entries the _vhosts will be set to null- Parameters:
virtualHosts
- Array of virtual hosts that this context responds to. A null/empty array means any hostname is acceptable. Host names may be String representation of IP addresses. Host names may start with '*.' to wildcard one level of names. Hosts and wildcard hosts may be followed with '@connectorname', in which case they will match only if the theConnector.getName()
for the request also matches. If an entry is just '@connectorname' it will match any host if that connector was used. Note - In previous versions if one or more connectorname only entries existed and non of the connectors matched the handler would not match regardless of any hostname entries. If there is one or more connectorname only entries and one or more host only entries but no hostname and connector entries we assume the old behavior and will log a warning. The warning can be removed by removing the host entries that were previously being ignored, or modifying to include a hostname and connectorname entry.
-
getVirtualHosts
@ManagedAttribute(value="Virtual hosts accepted by the context", readonly=true) public String[] getVirtualHosts()Get the virtual hosts for the context. Only requests that have a matching host header or fully qualified URL will be passed to that context with a virtual host name. A context with no virtual host names or a null virtual host name is available to all requests that are not served by a context with a matching virtual host name.- Returns:
- Array of virtual hosts that this context responds to. A null/empty array means any hostname is acceptable. Host names may be String
representation of IP addresses. Host names may start with '*.' to wildcard one level of names. Hosts and wildcard hosts may be followed with
'@connectorname', in which case they will match only if the the
Connector.getName()
for the request also matches. If an entry is just '@connectorname' it will match any host if that connector was used. Note - In previous versions if one or more connectorname only entries existed and non of the connectors matched the handler would not match regardless of any hostname entries. If there is one or more connectorname only entries and one or more host only entries but no hostname and connector entries we assume the old behavior and will log a warning. The warning can be removed by removing the host entries that were previously being ignored, or modifying to include a hostname and connectorname entry.
-
getAttribute
- Specified by:
getAttribute
in interfaceAttributes
-
getAttributeNames
- Specified by:
getAttributeNames
in interfaceAttributes
-
getAttributeNameSet
- Specified by:
getAttributeNameSet
in interfaceAttributes
-
getAttributes
- Returns:
- Returns the attributes.
-
getClassLoader
- Returns:
- Returns the classLoader.
-
getClassPath
Make best effort to extract a file classpath from the context classloader- Returns:
- Returns the classLoader.
-
getContextPath
@ManagedAttribute("True if URLs are compacted to replace the multiple \'/\'s with a single \'/\'") public String getContextPath()- Returns:
- Returns the contextPath.
-
getContextPathEncoded
- Returns:
- Returns the encoded contextPath.
-
getRequestContextPath
Get the context path in a form suitable to be returned fromHttpServletRequest.getContextPath()
orServletContext.getContextPath()
.- Returns:
- Returns the encoded contextPath, or empty string for root context
-
getInitParameter
-
setInitParameter
-
getInitParameterNames
-
getInitParams
@ManagedAttribute("Initial Parameter map for the context") public Map<String,String> getInitParams()- Returns:
- Returns the initParams.
-
getDisplayName
@ManagedAttribute(value="Display name of the Context", readonly=true) public String getDisplayName() -
addEventListener
Add a context event listeners.- Specified by:
addEventListener
in interfaceContainer
- Specified by:
addEventListener
in interfaceLifeCycle
- Overrides:
addEventListener
in classContainerLifeCycle
- Parameters:
listener
- the event listener to add- Returns:
- true if the listener was added
- See Also:
-
ContextHandler.ContextScopeListener
ServletContextListener
ServletContextAttributeListener
ServletRequestListener
ServletRequestAttributeListener
-
removeEventListener
Description copied from interface:Container
Remove an event listener.- Specified by:
removeEventListener
in interfaceContainer
- Specified by:
removeEventListener
in interfaceLifeCycle
- Overrides:
removeEventListener
in classContainerLifeCycle
- Parameters:
listener
- the listener to remove- Returns:
- true if the listener was removed
- See Also:
-
addProgrammaticListener
Apply any necessary restrictions on a programmatic added listener.- Parameters:
listener
- the programmatic listener to add
-
isProgrammaticListener
-
isDurableListener
-
isShutdown
@ManagedAttribute("true for graceful shutdown, which allows existing requests to complete") public boolean isShutdown()- Specified by:
isShutdown
in interfaceGraceful
- Returns:
- true if this context is shutting down
-
shutdown
Set shutdown status. This field allows for graceful shutdown of a context. A started context may be put into non accepting state so that existing requests can complete, but no new requests are accepted. -
isAvailable
public boolean isAvailable()- Returns:
- false if this context is unavailable (sends 503)
-
setAvailable
public void setAvailable(boolean available) Set Available status.- Parameters:
available
- true to set as enabled
-
getLogger
public org.slf4j.Logger getLogger() -
setLogger
public void setLogger(org.slf4j.Logger logger) -
doStart
Description copied from class:ContainerLifeCycle
Starts the managed lifecycle beans in the order they were added.- Overrides:
doStart
in classScopedHandler
- Throws:
AbstractLifeCycle.StopException
- If thrown, the lifecycle will immediately be stopped.Exception
- If there was a problem starting. Will cause a transition to FAILED state
-
startContext
Extensible startContext. this method is called fromdoStart()
instead of a call to super.doStart(). This allows derived classes to insert additional handling (Eg configuration) before the call to super.doStart by this method will start contained handlers.- Throws:
Exception
- if unable to start the context- See Also:
-
contextInitialized
Call the ServletContextListeners contextInitialized methods. This can be called from a ServletHandler during the proper sequence of initializing filters, servlets and listeners. However, if there is no ServletHandler, the ContextHandler will call this method during doStart().- Throws:
Exception
-
contextDestroyed
Call the ServletContextListeners with contextDestroyed. This method can be called from a ServletHandler in the proper sequence of destroying filters, servlets and listeners. If there is no ServletHandler, the ContextHandler must ensure these listeners are called instead.- Throws:
Exception
-
stopContext
- Throws:
Exception
-
callContextInitialized
protected void callContextInitialized(javax.servlet.ServletContextListener l, javax.servlet.ServletContextEvent e) -
callContextDestroyed
protected void callContextDestroyed(javax.servlet.ServletContextListener l, javax.servlet.ServletContextEvent e) -
doStop
Description copied from class:ContainerLifeCycle
Stops the managed lifecycle beans in the reverse order they were added.- Overrides:
doStop
in classAbstractHandler
- Throws:
Exception
- If there was a problem stopping. Will cause a transition to FAILED state
-
checkVirtualHost
-
checkContextPath
-
checkContext
public boolean checkContext(String target, Request baseRequest, javax.servlet.http.HttpServletResponse response) throws IOException - Throws:
IOException
-
doScope
public void doScope(String target, Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException Description copied from class:ScopedHandler
Scope the handlerDerived implementations should call
ScopedHandler.nextScope(String, Request, HttpServletRequest, HttpServletResponse)
- Overrides:
doScope
in classScopedHandler
- Parameters:
target
- The target of the request - either a URI or a name.baseRequest
- The original unwrapped request object.request
- The request either as theRequest
object or a wrapper of that request. The
method can be used access the Request object if required.HttpConnection.getCurrentConnection()
.getHttpChannel()
.getRequest()
response
- The response as theResponse
object or a wrapper of that request. The
method can be used access the Response object if required.HttpConnection.getCurrentConnection()
.getHttpChannel()
.getResponse()
- Throws:
IOException
- if unable to handle the request or response processingjavax.servlet.ServletException
- if unable to handle the request or response due to underlying servlet issue
-
requestInitialized
protected void requestInitialized(Request baseRequest, javax.servlet.http.HttpServletRequest request) -
requestDestroyed
-
doHandle
public void doHandle(String target, Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException Description copied from class:ScopedHandler
Do the handler work within the scope.Derived implementations should call
ScopedHandler.nextHandle(String, Request, HttpServletRequest, HttpServletResponse)
- Specified by:
doHandle
in classScopedHandler
- Parameters:
target
- The target of the request - either a URI or a name.baseRequest
- The original unwrapped request object.request
- The request either as theRequest
object or a wrapper of that request. The
method can be used access the Request object if required.HttpConnection.getCurrentConnection()
.getHttpChannel()
.getRequest()
response
- The response as theResponse
object or a wrapper of that request. The
method can be used access the Response object if required.HttpConnection.getCurrentConnection()
.getHttpChannel()
.getResponse()
- Throws:
IOException
- if unable to handle the request or response processingjavax.servlet.ServletException
- if unable to handle the request or response due to underlying servlet issue
-
enterScope
- Parameters:
request
- A request that is applicable to the scope, or nullreason
- An object that indicates the reason the scope is being entered.
-
exitScope
- Parameters:
request
- A request that is applicable to the scope, or null
-
handle
Handle a runnable in the scope of this context and a particular request- Parameters:
request
- The request to scope the thread to (may be null if no particular request is in scope)runnable
- The runnable to run.
-
handle
-
isProtectedTarget
Check the target. Called byScopedHandler.handle(String, Request, HttpServletRequest, HttpServletResponse)
when a target within a context is determined. If the target is protected, 404 is returned.- Parameters:
target
- the target to test- Returns:
- true if target is a protected target
-
setProtectedTargets
- Parameters:
targets
- Array of URL prefix. Each prefix is in the form /path and will match either /path exactly or /path/anything
-
getProtectedTargets
-
removeAttribute
- Specified by:
removeAttribute
in interfaceAttributes
-
setAttribute
- Specified by:
setAttribute
in interfaceAttributes
-
setAttributes
- Parameters:
attributes
- The attributes to set.
-
clearAttributes
public void clearAttributes()- Specified by:
clearAttributes
in interfaceAttributes
-
setClassLoader
- Parameters:
classLoader
- The classLoader to set.
-
setDefaultContextPath
Set the default context path. A default context path may be overriden by a default-context-path element in a web.xml- Parameters:
contextPath
- The _contextPath to set.
-
setDefaultRequestCharacterEncoding
-
getDefaultRequestCharacterEncoding
-
setDefaultResponseCharacterEncoding
-
getDefaultResponseCharacterEncoding
-
isContextPathDefault
public boolean isContextPathDefault()- Returns:
- True if the current contextPath is from default settings
-
setContextPath
- Parameters:
contextPath
- The _contextPath to set.
-
setDisplayName
- Parameters:
servletContextName
- The servletContextName to set.
-
getBaseResource
- Returns:
- Returns the resourceBase.
-
getResourceBase
- Returns:
- Returns the base resource as a string.
-
setBaseResource
Set the base resource for this context.- Parameters:
base
- The resource used as the base for all static content of this context.- See Also:
-
setResourceBase
Set the base resource for this context.- Parameters:
resourceBase
- A string representing the base resource for the context. Any string accepted byResource.newResource(String)
may be passed and the call is equivalent tosetBaseResource(newResource(resourceBase));
-
getMimeTypes
- Returns:
- Returns the mimeTypes.
-
setMimeTypes
- Parameters:
mimeTypes
- The mimeTypes to set.
-
setWelcomeFiles
-
getWelcomeFiles
@ManagedAttribute(value="Partial URIs of directory welcome files", readonly=true) public String[] getWelcomeFiles()- Returns:
- The names of the files which the server should consider to be welcome files in this context.
- See Also:
-
getErrorHandler
- Returns:
- Returns the errorHandler.
-
setErrorHandler
- Parameters:
errorHandler
- The errorHandler to set.
-
getMaxFormContentSize
-
setMaxFormContentSize
public void setMaxFormContentSize(int maxSize) Set the maximum size of a form post, to protect against DOS attacks from large forms.- Parameters:
maxSize
- the maximum size of the form content (in bytes)
-
getMaxFormKeys
public int getMaxFormKeys() -
setMaxFormKeys
public void setMaxFormKeys(int max) Set the maximum number of form Keys to protect against DOS attack from crafted hash keys.- Parameters:
max
- the maximum number of form keys
-
isCompactPath
Deprecated.useCompactPathRule
withRewriteHandler
instead.- Returns:
- True if URLs are compacted to replace multiple '/'s with a single '/'
-
setCompactPath
Deprecated.- Parameters:
compactPath
- True if URLs are compacted to replace multiple '/'s with a single '/'
-
toString
- Overrides:
toString
in classAbstractLifeCycle
-
loadClass
- Throws:
ClassNotFoundException
-
addLocaleEncoding
-
getLocaleEncoding
-
getLocaleEncoding
Get the character encoding for a locale. The full locale name is first looked up in the map of encodings. If no encoding is found, then the locale language is looked up.- Parameters:
locale
- aLocale
value- Returns:
- a
String
representing the character encoding for the locale or null if none found.
-
getLocaleEncodings
Get all of the locale encodings- Returns:
- a map of all the locale encodings: key is name of the locale and value is the char encoding
-
getResource
Attempt to get a Resource from the Context.- Parameters:
pathInContext
- the path within the base resource to attempt to get- Returns:
- the resource, or null if not available.
- Throws:
MalformedURLException
- if unable to form a Resource from the provided path
-
checkAlias
- Parameters:
path
- the path to check the alias forresource
- the resource- Returns:
- True if the alias is OK
-
newResource
Convert URL to Resource wrapper forResource.newResource(URL)
enables extensions to provide alternate resource implementations.- Parameters:
url
- the url to convert to a Resource- Returns:
- the Resource for that url
- Throws:
IOException
- if unable to create a Resource from the URL
-
newResource
Convert URL to Resource wrapper forResource.newResource(URL)
enables extensions to provide alternate resource implementations.- Parameters:
uri
- the URI to convert to a Resource- Returns:
- the Resource for that URI
- Throws:
IOException
- if unable to create a Resource from the URL
-
newResource
Convert a URL or path to a Resource. The default implementation is a wrapper forResource.newResource(String)
.- Parameters:
urlOrPath
- The URL or path to convert- Returns:
- The Resource for the URL/path
- Throws:
IOException
- The Resource could not be created.
-
getResourcePaths
-
addAliasCheck
Add an AliasCheck instance to possibly permit aliased resources- Parameters:
check
- The alias checker
-
getAliasChecks
- Returns:
- Immutable list of Alias checks
-
setAliasChecks
- Parameters:
checks
- list of AliasCheck instances
-
clearAliasChecks
public void clearAliasChecks()clear the list of AliasChecks
-
AllowedResourceAliasChecker
instead.