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