- All Known Subinterfaces:
WebApplication
- All Known Implementing Classes:
DefaultWebApplication
public interface ServletContext
The servlet context API.
- Author:
- Manfred Riem ([email protected])
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ORDERED_LIBS
Defines the ORDERED_LIBS constant.static java.lang.String
TEMPDIR
Defines the TEMPDIR constant. -
Method Summary
Modifier and Type Method Description FilterRegistration.Dynamic
addFilter(java.lang.String filterName, java.lang.Class<? extends Filter> filterClass)
Add the filter.FilterRegistration.Dynamic
addFilter(java.lang.String filterName, java.lang.String className)
Add the filter.FilterRegistration.Dynamic
addFilter(java.lang.String filterName, Filter filter)
Add the filter.ServletRegistration.Dynamic
addJspFile(java.lang.String servletName, java.lang.String jspFile)
Add a JSP file.void
addListener(java.lang.Class<? extends java.util.EventListener> listenerClass)
Add the listener.void
addListener(java.lang.String className)
Add the listener.<T extends java.util.EventListener>
voidaddListener(T listener)
Add the listener.ServletRegistration.Dynamic
addServlet(java.lang.String servletName, java.lang.Class<? extends Servlet> servletClass)
Add the servlet.ServletRegistration.Dynamic
addServlet(java.lang.String servletName, java.lang.String className)
Add the servlet.ServletRegistration.Dynamic
addServlet(java.lang.String servletName, Servlet servlet)
Add the servlet.<T extends Filter>
TcreateFilter(java.lang.Class<T> clazz)
Create the filter.<T extends java.util.EventListener>
TcreateListener(java.lang.Class<T> clazz)
Create the listener.<T extends Servlet>
TcreateServlet(java.lang.Class<T> clazz)
Create the servlet.void
declareRoles(java.lang.String... roles)
Declare the roles.java.lang.Object
getAttribute(java.lang.String name)
Get the attribute.java.util.Enumeration<java.lang.String>
getAttributeNames()
Get the attribute names.java.lang.ClassLoader
getClassLoader()
Get the class loader.ServletContext
getContext(java.lang.String path)
Get the servlet context for the given path.java.lang.String
getContextPath()
Get the context path.java.util.Set<SessionTrackingMode>
getDefaultSessionTrackingModes()
Get the default session tracking modes.int
getEffectiveMajorVersion()
Get the effective major version.int
getEffectiveMinorVersion()
Get the effective minor version.java.util.Set<SessionTrackingMode>
getEffectiveSessionTrackingModes()
Get the effective session tracking modes.FilterRegistration
getFilterRegistration(java.lang.String filterName)
Get the filter registration.java.util.Map<java.lang.String,? extends FilterRegistration>
getFilterRegistrations()
Get the filter registrations.java.lang.String
getInitParameter(java.lang.String name)
Get the init parameter.java.util.Enumeration<java.lang.String>
getInitParameterNames()
Get the init parameter names.JspConfigDescriptor
getJspConfigDescriptor()
Get the JSP config descriptor.int
getMajorVersion()
Get the major version.java.lang.String
getMimeType(java.lang.String filename)
Get the mime type.int
getMinorVersion()
Get the minor version.RequestDispatcher
getNamedDispatcher(java.lang.String name)
Get the named dispatcher.java.lang.String
getRealPath(java.lang.String path)
Get the real path.java.lang.String
getRequestCharacterEncoding()
Get the default request character encoding.RequestDispatcher
getRequestDispatcher(java.lang.String path)
Get the request dispatcher.java.net.URL
getResource(java.lang.String path)
Get the resource.java.io.InputStream
getResourceAsStream(java.lang.String path)
Get the resource as a stream.java.util.Set<java.lang.String>
getResourcePaths(java.lang.String path)
Get the resource paths for the given path.java.lang.String
getResponseCharacterEncoding()
Get the default response character encoding.java.lang.String
getServerInfo()
Get the server info.Servlet
getServlet(java.lang.String name)
Deprecated.java.lang.String
getServletContextName()
Get the servlet context name.java.util.Enumeration<java.lang.String>
getServletNames()
Deprecated.ServletRegistration
getServletRegistration(java.lang.String servletName)
Get the servlet registration.java.util.Map<java.lang.String,? extends ServletRegistration>
getServletRegistrations()
Get the servlet registrations.java.util.Enumeration<Servlet>
getServlets()
Deprecated.SessionCookieConfig
getSessionCookieConfig()
Get the session cookie config.int
getSessionTimeout()
Get the default session timeout.java.lang.String
getVirtualServerName()
Get the virtual server name.void
log(java.lang.Exception exception, java.lang.String message)
Deprecated.void
log(java.lang.String message)
Log the specified message.void
log(java.lang.String message, java.lang.Throwable throwable)
Log the message and throwable.void
removeAttribute(java.lang.String name)
Remove the attribute.void
setAttribute(java.lang.String name, java.lang.Object object)
Set the attribute.boolean
setInitParameter(java.lang.String name, java.lang.String value)
Set the init parameter.void
setRequestCharacterEncoding(java.lang.String requestCharacterEncoding)
Set the default request character encoding.void
setResponseCharacterEncoding(java.lang.String responseCharacterEncoding)
Set the default response character encoding.void
setSessionTimeout(int sessionTimeout)
Set the default session timeout.void
setSessionTrackingModes(java.util.Set<SessionTrackingMode> sessionTrackingModes)
Set the session tracking modes.
-
Field Details
-
ORDERED_LIBS
static final java.lang.String ORDERED_LIBSDefines the ORDERED_LIBS constant.- See Also:
- Constant Field Values
-
TEMPDIR
static final java.lang.String TEMPDIRDefines the TEMPDIR constant.- See Also:
- Constant Field Values
-
-
Method Details
-
addFilter
Add the filter.- Parameters:
filterName
- the filter name.className
- the class name.- Returns:
- the dynamic filter registration.
-
addFilter
Add the filter.- Parameters:
filterName
- the filter name.filter
- the filter.- Returns:
- the dynamic filter registration.
-
addFilter
FilterRegistration.Dynamic addFilter(java.lang.String filterName, java.lang.Class<? extends Filter> filterClass)Add the filter.- Parameters:
filterName
- the filter name.filterClass
- the filter class.- Returns:
- the dynamic filter registration.
-
addJspFile
Add a JSP file.- Parameters:
servletName
- the name of the servlet to be used.jspFile
- the path of the JSP file.- Returns:
- the dynamic servlet registration.
-
addListener
void addListener(java.lang.String className)Add the listener.- Parameters:
className
- the class name.
-
addListener
<T extends java.util.EventListener> void addListener(T listener)Add the listener.- Type Parameters:
T
- the type.- Parameters:
listener
- the listener.
-
addListener
void addListener(java.lang.Class<? extends java.util.EventListener> listenerClass)Add the listener.- Parameters:
listenerClass
- the listener class.
-
addServlet
Add the servlet.- Parameters:
servletName
- the servlet name.className
- the class name.- Returns:
- the servlet dynamic registration.
-
addServlet
Add the servlet.- Parameters:
servletName
- the servlet name.servlet
- the servlet.- Returns:
- the dynamic servlet registration.
-
addServlet
ServletRegistration.Dynamic addServlet(java.lang.String servletName, java.lang.Class<? extends Servlet> servletClass)Add the servlet.- Parameters:
servletName
- the servlet name.servletClass
- the servlet class.- Returns:
- the dynamic servlet registration.
-
createFilter
Create the filter.- Type Parameters:
T
- the filter type.- Parameters:
clazz
- the class.- Returns:
- the filter.
- Throws:
ServletException
- when a servlet error occurs.
-
createListener
<T extends java.util.EventListener> T createListener(java.lang.Class<T> clazz) throws ServletExceptionCreate the listener.- Type Parameters:
T
- the listener type.- Parameters:
clazz
- the class.- Returns:
- the listener.
- Throws:
ServletException
- when a servlet error occurs.
-
createServlet
Create the servlet.- Type Parameters:
T
- the servlet type.- Parameters:
clazz
- the class.- Returns:
- the created servlet.
- Throws:
ServletException
- when a servlet error occurs.
-
declareRoles
void declareRoles(java.lang.String... roles)Declare the roles.- Parameters:
roles
- the roles.
-
getAttribute
java.lang.Object getAttribute(java.lang.String name)Get the attribute.- Parameters:
name
- the name.- Returns:
- the value, or null.
-
getAttributeNames
java.util.Enumeration<java.lang.String> getAttributeNames()Get the attribute names.- Returns:
- the attribute names.
-
getClassLoader
java.lang.ClassLoader getClassLoader()Get the class loader.- Returns:
- the class loader.
-
getContext
Get the servlet context for the given path.- Parameters:
path
- the path.- Returns:
- the servlet context, or null if not found (or not supported).
-
getContextPath
java.lang.String getContextPath()Get the context path.- Returns:
- the context path.
-
getDefaultSessionTrackingModes
java.util.Set<SessionTrackingMode> getDefaultSessionTrackingModes()Get the default session tracking modes.- Returns:
- the default session tracking modes.
-
getEffectiveMajorVersion
int getEffectiveMajorVersion()Get the effective major version.- Returns:
- the effective major version.
-
getEffectiveMinorVersion
int getEffectiveMinorVersion()Get the effective minor version.- Returns:
- the effective minor version.
-
getEffectiveSessionTrackingModes
java.util.Set<SessionTrackingMode> getEffectiveSessionTrackingModes()Get the effective session tracking modes.- Returns:
- the effective session tracking modes.
-
getFilterRegistration
Get the filter registration.- Parameters:
filterName
- the filter name.- Returns:
- the
-
getFilterRegistrations
java.util.Map<java.lang.String,? extends FilterRegistration> getFilterRegistrations()Get the filter registrations.- Returns:
- the filter registrations.
-
getInitParameter
java.lang.String getInitParameter(java.lang.String name)Get the init parameter.- Parameters:
name
- the name.- Returns:
- the value, or null if not found.
-
getInitParameterNames
java.util.Enumeration<java.lang.String> getInitParameterNames()Get the init parameter names.- Returns:
- the init parameter names.
-
getJspConfigDescriptor
JspConfigDescriptor getJspConfigDescriptor()Get the JSP config descriptor.- Returns:
- the JSP config descriptor.
-
getMajorVersion
int getMajorVersion()Get the major version.- Returns:
- the major version.
-
getMimeType
java.lang.String getMimeType(java.lang.String filename)Get the mime type.- Parameters:
filename
- the filename.- Returns:
- the mime type, or null.
-
getMinorVersion
int getMinorVersion()Get the minor version.- Returns:
- the minor version.
-
getNamedDispatcher
Get the named dispatcher.- Parameters:
name
- the name.- Returns:
- the request dispatcher, or null if not found.
-
getRealPath
java.lang.String getRealPath(java.lang.String path)Get the real path.- Parameters:
path
- the path.- Returns:
- the real path.
-
getRequestCharacterEncoding
java.lang.String getRequestCharacterEncoding()Get the default request character encoding.- Returns:
- the default request character encoding.
-
getRequestDispatcher
Get the request dispatcher.- Parameters:
path
- the path.- Returns:
- the request dispatcher, or null.
-
getResponseCharacterEncoding
java.lang.String getResponseCharacterEncoding()Get the default response character encoding.- Returns:
- the default response character encoding.
-
getResource
java.net.URL getResource(java.lang.String path) throws java.net.MalformedURLExceptionGet the resource.- Parameters:
path
- the path.- Returns:
- the URL, or null if not found.
- Throws:
java.net.MalformedURLException
- when the path is malformed.
-
getResourceAsStream
java.io.InputStream getResourceAsStream(java.lang.String path)Get the resource as a stream.- Parameters:
path
- the path.- Returns:
- the input stream, or null.
-
getResourcePaths
java.util.Set<java.lang.String> getResourcePaths(java.lang.String path)Get the resource paths for the given path.- Parameters:
path
- the path.- Returns:
- the resource paths.
-
getServerInfo
java.lang.String getServerInfo()Get the server info.- Returns:
- the server info.
-
getServlet
Deprecated.Get the servlet.- Parameters:
name
- the name.- Returns:
- null
- Throws:
ServletException
- when a servlet error occurs.
-
getServletContextName
java.lang.String getServletContextName()Get the servlet context name.- Returns:
- the servlet context name.
-
getServletNames
@Deprecated java.util.Enumeration<java.lang.String> getServletNames()Deprecated.Get the servlet names.- Returns:
- an empty enumeration.
-
getServletRegistration
Get the servlet registration.- Parameters:
servletName
- the servlet name.- Returns:
- the servlet registration, or null if not found.
-
getServletRegistrations
java.util.Map<java.lang.String,? extends ServletRegistration> getServletRegistrations()Get the servlet registrations.- Returns:
- the servlet registrations.
-
getServlets
Deprecated.Get the servlets.- Returns:
- an empty enumeration.
-
getSessionCookieConfig
SessionCookieConfig getSessionCookieConfig()Get the session cookie config.- Returns:
- the session cookie config.
-
getSessionTimeout
int getSessionTimeout()Get the default session timeout.- Returns:
- the default session timeout.
-
getVirtualServerName
java.lang.String getVirtualServerName()Get the virtual server name.- Returns:
- the virtual server name.
-
log
void log(java.lang.String message)Log the specified message.- Parameters:
message
- the message.
-
log
@Deprecated void log(java.lang.Exception exception, java.lang.String message)Deprecated.Log the exception and message.- Parameters:
exception
- the exception.message
- the message.
-
log
void log(java.lang.String message, java.lang.Throwable throwable)Log the message and throwable.- Parameters:
message
- the message.throwable
- the throwable.
-
removeAttribute
void removeAttribute(java.lang.String name)Remove the attribute.- Parameters:
name
- the name.
-
setAttribute
void setAttribute(java.lang.String name, java.lang.Object object)Set the attribute.- Parameters:
name
- the name.object
- the object value.
-
setInitParameter
boolean setInitParameter(java.lang.String name, java.lang.String value)Set the init parameter.- Parameters:
name
- the name.value
- the value.- Returns:
- true if it was set, false otherwise.
-
setRequestCharacterEncoding
void setRequestCharacterEncoding(java.lang.String requestCharacterEncoding)Set the default request character encoding.- Parameters:
requestCharacterEncoding
- the default request character encoding.
-
setResponseCharacterEncoding
void setResponseCharacterEncoding(java.lang.String responseCharacterEncoding)Set the default response character encoding.- Parameters:
responseCharacterEncoding
- the default response character encoding.
-
setSessionTimeout
void setSessionTimeout(int sessionTimeout)Set the default session timeout.- Parameters:
sessionTimeout
- the default session timeout.
-
setSessionTrackingModes
Set the session tracking modes.- Parameters:
sessionTrackingModes
- the session tracking modes.
-