public class ApplicationContext extends Object implements javax.servlet.ServletContext
ServletContext that represents
a web application's execution environment. An instance of this class is
associated with each instance of StandardContext.| Constructor and Description |
|---|
ApplicationContext(StandardContext context)
Construct a new instance of this class, associated with the specified
Context instance.
|
| Modifier and Type | Method and Description |
|---|---|
javax.servlet.FilterRegistration.Dynamic |
addFilter(String filterName,
Class<? extends javax.servlet.Filter> filterClass)
Adds the filter with the given name and class type to this servlet
context.
|
javax.servlet.FilterRegistration.Dynamic |
addFilter(String filterName,
javax.servlet.Filter filter) |
javax.servlet.FilterRegistration.Dynamic |
addFilter(String filterName,
String className)
Adds the filter with the given name and class name to this servlet
context.
|
void |
addListener(Class<? extends EventListener> listenerClass)
Adds a listener of the given class type to this ServletContext.
|
void |
addListener(String className)
Adds the listener with the given class name to this ServletContext.
|
<T extends EventListener> |
addListener(T t)
Adds the given listener to this ServletContext.
|
javax.servlet.ServletRegistration.Dynamic |
addServlet(String servletName,
Class<? extends javax.servlet.Servlet> servletClass) |
javax.servlet.ServletRegistration.Dynamic |
addServlet(String servletName,
javax.servlet.Servlet servlet) |
javax.servlet.ServletRegistration.Dynamic |
addServlet(String servletName,
String className) |
<T extends javax.servlet.Filter> |
createFilter(Class<T> clazz)
Instantiates the given Filter class and performs any required
resource injection into the new Filter instance before returning
it.
|
<T extends EventListener> |
createListener(Class<T> clazz)
Instantiates the given EventListener class and performs any
required resource injection into the new EventListener instance
before returning it.
|
<T extends javax.servlet.Servlet> |
createServlet(Class<T> clazz)
Instantiates the given Servlet class and performs any required
resource injection into the new Servlet instance before returning
it.
|
void |
declareRoles(String... roleNames) |
Object |
getAttribute(String name)
Return the value of the specified context attribute, if any;
otherwise return
null. |
Enumeration<String> |
getAttributeNames()
Return an enumeration of the names of the context attributes
associated with this context.
|
ClassLoader |
getClassLoader() |
javax.servlet.ServletContext |
getContext(String uri)
Return a
ServletContext object that corresponds to a
specified URI on the server. |
String |
getContextPath()
Returns the context path of the web application.
|
Set<javax.servlet.SessionTrackingMode> |
getDefaultSessionTrackingModes()
Gets the session tracking modes that are supported by default for this
ServletContext.
|
int |
getEffectiveMajorVersion()
Gets the major version of the Servlet specification that the
application represented by this ServletContext is based on.
|
int |
getEffectiveMinorVersion()
Gets the minor version of the Servlet specification that the
application represented by this ServletContext is based on.
|
Set<javax.servlet.SessionTrackingMode> |
getEffectiveSessionTrackingModes()
Gets the session tracking modes that are in effect for this
ServletContext.
|
protected javax.servlet.ServletContext |
getFacade()
Return the facade associated with this ApplicationContext.
|
javax.servlet.FilterRegistration |
getFilterRegistration(String filterName)
Gets the FilterRegistration corresponding to the filter with the
given filterName.
|
Map<String,? extends javax.servlet.FilterRegistration> |
getFilterRegistrations()
Gets a Map of the FilterRegistration objects corresponding to all
currently registered filters.
|
String |
getInitParameter(String name)
Return the value of the specified initialization parameter, or
null if this parameter does not exist. |
Enumeration<String> |
getInitParameterNames()
Return the names of the context's initialization parameters, or an
empty enumeration if the context has no initialization parameters.
|
javax.servlet.descriptor.JspConfigDescriptor |
getJspConfigDescriptor()
Gets the
<jsp-config> related configuration
that was aggregated from the web.xml and
web-fragment.xml descriptor files of the web application
represented by this ServletContext. |
int |
getMajorVersion()
Return the major version of the Java Servlet API that we implement.
|
String |
getMimeType(String file)
Return the MIME type of the specified file, or
null if
the MIME type cannot be determined. |
int |
getMinorVersion()
Return the minor version of the Java Servlet API that we implement.
|
javax.servlet.RequestDispatcher |
getNamedDispatcher(String name)
Return a
RequestDispatcher object that acts as a
wrapper for the named servlet. |
String |
getRealPath(String path) |
javax.servlet.RequestDispatcher |
getRequestDispatcher(String path)
Return a
RequestDispatcher instance that acts as a
wrapper for the resource at the given path. |
URL |
getResource(String path)
Return the URL to the resource that is mapped to a specified path.
|
InputStream |
getResourceAsStream(String path)
Return the requested resource as an
InputStream. |
Set<String> |
getResourcePaths(String path)
Return a Set containing the resource paths of resources member of the
specified collection.
|
DirContext |
getResources()
Return the resources object that is mapped to a specified path.
|
String |
getServerInfo()
Return the name and version of the servlet container.
|
javax.servlet.Servlet |
getServlet(String name)
Deprecated.
As of Java Servlet API 2.1, with no direct replacement.
|
String |
getServletContextName()
Return the display name of this web application.
|
Enumeration<String> |
getServletNames()
Deprecated.
As of Java Servlet API 2.1, with no direct replacement.
|
javax.servlet.ServletRegistration |
getServletRegistration(String servletName)
Gets the ServletRegistration corresponding to the servlet with the
given servletName.
|
Map<String,? extends javax.servlet.ServletRegistration> |
getServletRegistrations()
Gets a Map of the ServletRegistration objects corresponding to all
currently registered servlets.
|
Enumeration<javax.servlet.Servlet> |
getServlets()
Deprecated.
As of Java Servlet API 2.1, with no direct replacement.
|
javax.servlet.SessionCookieConfig |
getSessionCookieConfig()
Gets the SessionCookieConfig object through which various
properties of the session tracking cookies created on behalf of this
ServletContext may be configured.
|
StandardContext |
getStandardContext() |
String |
getVirtualServerName() |
void |
log(Exception exception,
String message)
Deprecated.
As of Java Servlet API 2.1, use
log(String, Throwable) instead |
void |
log(String message)
Writes the specified message to a servlet log file.
|
void |
log(String message,
Throwable throwable)
Writes the specified message and exception to a servlet log file.
|
void |
removeAttribute(String name)
Remove the context attribute with the specified name, if any.
|
void |
setAttribute(String name,
Object value)
Bind the specified value with the specified context attribute name,
replacing any existing value for that name.
|
boolean |
setInitParameter(String name,
String value) |
void |
setSessionTrackingModes(Set<javax.servlet.SessionTrackingMode> sessionTrackingModes)
Sets the session tracking modes that are to become effective for this
ServletContext.
|
public ApplicationContext(StandardContext context)
context - The associated Context instancepublic StandardContext getStandardContext()
public DirContext getResources()
public Object getAttribute(String name)
null.getAttribute in interface javax.servlet.ServletContextname - Name of the context attribute to returnpublic Enumeration<String> getAttributeNames()
getAttributeNames in interface javax.servlet.ServletContextpublic String getContextPath()
The context path is the portion of the request URI that is used to select the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "".
It is possible that a servlet container may match a context by
more than one context path. In such cases the
javax.servlet.http.HttpServletRequest#getContextPath()
will return the actual context path used by the request and it may
differ from the path returned by this method.
The context path returned by this method should be considered as the
prime or preferred context path of the application.
javax.servlet.http.HttpServletRequest#getContextPath()public javax.servlet.ServletContext getContext(String uri)
ServletContext object that corresponds to a
specified URI on the server. This method allows servlets to gain
access to the context for various parts of the server, and as needed
obtain RequestDispatcher objects or resources from the
context. The given path must be absolute (beginning with a "/"),
and is interpreted based on our virtual host's document root.getContext in interface javax.servlet.ServletContexturi - Absolute URI of a resource on the serverpublic String getInitParameter(String name)
null if this parameter does not exist.name - Name of the initialization parameter to retrievepublic Enumeration<String> getInitParameterNames()
public boolean setInitParameter(String name, String value)
public int getMajorVersion()
getMajorVersion in interface javax.servlet.ServletContextpublic int getMinorVersion()
getMinorVersion in interface javax.servlet.ServletContextpublic int getEffectiveMajorVersion()
public int getEffectiveMinorVersion()
public String getMimeType(String file)
null if
the MIME type cannot be determined.getMimeType in interface javax.servlet.ServletContextfile - Filename for which to identify a MIME typepublic javax.servlet.RequestDispatcher getNamedDispatcher(String name)
RequestDispatcher object that acts as a
wrapper for the named servlet.name - Name of the servlet for which a dispatcher is requestedpublic String getRealPath(String path)
getRealPath in interface javax.servlet.ServletContextpath - The virtual path to be translatednull if the container was unable to perform the
translationpublic javax.servlet.RequestDispatcher getRequestDispatcher(String path)
RequestDispatcher instance that acts as a
wrapper for the resource at the given path. The path must begin
with a "/" or be empty, and is interpreted as relative to the current
context root.getRequestDispatcher in interface javax.servlet.ServletContextpath - The path to the desired resource.public URL getResource(String path) throws MalformedURLException
getResource in interface javax.servlet.ServletContextpath - The path to the desired resourceMalformedURLException - if the path is not given
in the correct formpublic InputStream getResourceAsStream(String path)
InputStream. The
path must be specified according to the rules described under
getResource. If no such resource can be identified,
return null.getResourceAsStream in interface javax.servlet.ServletContextpath - The path to the desired resource.public Set<String> getResourcePaths(String path)
path - Collection pathpublic String getServerInfo()
getServerInfo in interface javax.servlet.ServletContextpublic javax.servlet.Servlet getServlet(String name)
getServlet in interface javax.servlet.ServletContextpublic String getServletContextName()
public Enumeration<String> getServletNames()
getServletNames in interface javax.servlet.ServletContextpublic Enumeration<javax.servlet.Servlet> getServlets()
getServlets in interface javax.servlet.ServletContextpublic void log(String message)
log in interface javax.servlet.ServletContextmessage - Message to be writtenpublic void log(Exception exception, String message)
log(String, Throwable) insteadlog in interface javax.servlet.ServletContextexception - Exception to be reportedmessage - Message to be writtenpublic void log(String message, Throwable throwable)
log in interface javax.servlet.ServletContextmessage - Message to be writtenthrowable - Exception to be reportedpublic void removeAttribute(String name)
removeAttribute in interface javax.servlet.ServletContextname - Name of the context attribute to be removedpublic void setAttribute(String name, Object value)
setAttribute in interface javax.servlet.ServletContextname - Attribute name to be boundvalue - New attribute value to be boundpublic javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, String className)
public javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, javax.servlet.Servlet servlet)
public javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, Class<? extends javax.servlet.Servlet> servletClass)
public <T extends javax.servlet.Servlet> T createServlet(Class<T> clazz) throws javax.servlet.ServletException
javax.servlet.ServletExceptionpublic javax.servlet.ServletRegistration getServletRegistration(String servletName)
public Map<String,? extends javax.servlet.ServletRegistration> getServletRegistrations()
public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, String className)
public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, javax.servlet.Filter filter)
public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, Class<? extends javax.servlet.Filter> filterClass)
public <T extends javax.servlet.Filter> T createFilter(Class<T> clazz) throws javax.servlet.ServletException
javax.servlet.ServletExceptionpublic javax.servlet.FilterRegistration getFilterRegistration(String filterName)
public Map<String,? extends javax.servlet.FilterRegistration> getFilterRegistrations()
public javax.servlet.SessionCookieConfig getSessionCookieConfig()
public void setSessionTrackingModes(Set<javax.servlet.SessionTrackingMode> sessionTrackingModes)
public Set<javax.servlet.SessionTrackingMode> getDefaultSessionTrackingModes()
public Set<javax.servlet.SessionTrackingMode> getEffectiveSessionTrackingModes()
public void addListener(String className)
public <T extends EventListener> void addListener(T t)
public void addListener(Class<? extends EventListener> listenerClass)
public <T extends EventListener> T createListener(Class<T> clazz) throws javax.servlet.ServletException
javax.servlet.ServletExceptionpublic javax.servlet.descriptor.JspConfigDescriptor getJspConfigDescriptor()
<jsp-config> related configuration
that was aggregated from the web.xml and
web-fragment.xml descriptor files of the web application
represented by this ServletContext.public ClassLoader getClassLoader()
public void declareRoles(String... roleNames)
public String getVirtualServerName()
protected javax.servlet.ServletContext getFacade()
Copyright © 2017. All rights reserved.