public class JspCServletContext extends Object implements ServletContext
ServletContext
implementation without
HTTP-specific methods.ORDERED_LIBS, TEMPDIR
Constructor and Description |
---|
JspCServletContext(PrintWriter aLogWriter,
URL aResourceBaseURL,
ClassLoader classLoader,
boolean validate,
boolean blockExternal)
Create a new instance of this ServletContext implementation.
|
Modifier and Type | Method and Description |
---|---|
FilterRegistration.Dynamic |
addFilter(String filterName,
Class<? extends Filter> filterClass)
Add filter to context.
|
FilterRegistration.Dynamic |
addFilter(String filterName,
Filter filter)
Add filter to context.
|
FilterRegistration.Dynamic |
addFilter(String filterName,
String className)
Add filter to context.
|
void |
addListener(Class<? extends EventListener> listenerClass)
TODO SERVLET3 - Add comments
|
void |
addListener(String className)
TODO SERVLET3 - Add comments
|
<T extends EventListener> |
addListener(T t)
TODO SERVLET3 - Add comments
|
ServletRegistration.Dynamic |
addServlet(String servletName,
Class<? extends Servlet> servletClass)
Add servlet to context.
|
ServletRegistration.Dynamic |
addServlet(String servletName,
Servlet servlet)
Register a servlet instance for use in this ServletContext.
|
ServletRegistration.Dynamic |
addServlet(String servletName,
String className)
Register a servlet implementation for use in this ServletContext.
|
<T extends Filter> |
createFilter(Class<T> c)
TODO SERVLET3 - Add comments
|
<T extends EventListener> |
createListener(Class<T> c)
TODO SERVLET3 - Add comments
|
<T extends Servlet> |
createServlet(Class<T> c)
TODO SERVLET3 - Add comments
|
void |
declareRoles(String... roleNames)
Add to the declared roles for this ServletContext.
|
Object |
getAttribute(String name)
Return the specified context attribute, if any.
|
Enumeration<String> |
getAttributeNames()
Return an enumeration of context attribute names.
|
ClassLoader |
getClassLoader()
Get the web application class loader associated with this ServletContext.
|
ServletContext |
getContext(String uripath)
Return the servlet context for the specified path.
|
String |
getContextPath()
Return the context path.
|
Set<SessionTrackingMode> |
getDefaultSessionTrackingModes()
Obtains the default session tracking modes for this web application.
|
int |
getEffectiveMajorVersion() |
int |
getEffectiveMinorVersion() |
Set<SessionTrackingMode> |
getEffectiveSessionTrackingModes()
Obtains the currently enabled session tracking modes for this web
application.
|
FilterRegistration |
getFilterRegistration(String filterName)
TODO SERVLET3 - Add comments
|
Map<String,? extends FilterRegistration> |
getFilterRegistrations() |
String |
getInitParameter(String name)
Return the specified context initialization parameter.
|
Enumeration<String> |
getInitParameterNames()
Return an enumeration of the names of context initialization
parameters.
|
JspConfigDescriptor |
getJspConfigDescriptor() |
int |
getMajorVersion()
Return the Servlet API major version number.
|
String |
getMimeType(String file)
Return the MIME type for the specified filename.
|
int |
getMinorVersion()
Return the Servlet API minor version number.
|
RequestDispatcher |
getNamedDispatcher(String name)
Return a request dispatcher for the specified servlet name.
|
String |
getRealPath(String path)
Return the real path for the specified context-relative
virtual path.
|
RequestDispatcher |
getRequestDispatcher(String path)
Return a request dispatcher for the specified context-relative path.
|
URL |
getResource(String path)
Return a URL object of a resource that is mapped to the
specified context-relative path.
|
InputStream |
getResourceAsStream(String path)
Return an InputStream allowing access to the resource at the
specified context-relative path.
|
Set<String> |
getResourcePaths(String path)
Return the set of resource paths for the "directory" at the
specified context path.
|
String |
getServerInfo()
Return descriptive information about this server.
|
Servlet |
getServlet(String name)
Deprecated.
This method has been deprecated with no replacement
|
String |
getServletContextName()
Return the name of this servlet context.
|
Enumeration<String> |
getServletNames()
Deprecated.
This method has been deprecated with no replacement
|
ServletRegistration |
getServletRegistration(String servletName)
Obtain the details of the named servlet.
|
Map<String,? extends ServletRegistration> |
getServletRegistrations()
TODO SERVLET3 - Add comments
|
Enumeration<Servlet> |
getServlets()
Deprecated.
This method has been deprecated with no replacement
|
SessionCookieConfig |
getSessionCookieConfig() |
String |
getVirtualServerName()
Get the primary name of the virtual host on which this context is
deployed.
|
void |
log(Exception exception,
String message)
Deprecated.
Use log(String,Throwable) instead
|
void |
log(String message)
Log the specified message.
|
void |
log(String message,
Throwable exception)
Log the specified message and exception.
|
void |
removeAttribute(String name)
Remove the specified context attribute.
|
void |
setAttribute(String name,
Object value)
Set or replace the specified context attribute.
|
boolean |
setInitParameter(String name,
String value)
Set the given initialisation parameter to the given value.
|
void |
setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
Configures the available session tracking modes for this web application.
|
public JspCServletContext(PrintWriter aLogWriter, URL aResourceBaseURL, ClassLoader classLoader, boolean validate, boolean blockExternal) throws JasperException
aLogWriter
- PrintWriter which is used for log()
callsaResourceBaseURL
- Resource base URLclassLoader
- Class loader for this ServletContext
validate
- Should a validating parser be used to parse web.xml?blockExternal
- Should external entities be blocked when parsing
web.xml?JasperException
- An error occurred building the merged web.xmlpublic Object getAttribute(String name)
getAttribute
in interface ServletContext
name
- Name of the requested attributeObject
containing the value of the attribute, or
null
if no attribute exists matching the given nameServletContext.getAttributeNames()
public Enumeration<String> getAttributeNames()
getAttributeNames
in interface ServletContext
Enumeration
of attribute namesServletContext.getAttribute(java.lang.String)
public ServletContext getContext(String uripath)
getContext
in interface ServletContext
uripath
- Server-relative path starting with '/'ServletContext
object that corresponds to the
named URL, or null if either none exists or the container wishes
to restrict this access.RequestDispatcher
public String getContextPath()
getContextPath
in interface ServletContext
public String getInitParameter(String name)
getInitParameter
in interface ServletContext
name
- Name of the requested parameterString
containing the value of the initialization
parameterServletConfig.getInitParameter(java.lang.String)
public Enumeration<String> getInitParameterNames()
getInitParameterNames
in interface ServletContext
Enumeration
of String
objects
containing the names of the context's initialization parametersServletConfig.getInitParameter(java.lang.String)
public int getMajorVersion()
getMajorVersion
in interface ServletContext
public String getMimeType(String file)
getMimeType
in interface ServletContext
file
- Filename whose MIME type is requestedString
specifying the file's MIME typepublic int getMinorVersion()
getMinorVersion
in interface ServletContext
public RequestDispatcher getNamedDispatcher(String name)
getNamedDispatcher
in interface ServletContext
name
- Name of the requested servletRequestDispatcher
object that acts as a wrapper for
the named servlet, or null
if the
ServletContext
cannot return a
RequestDispatcher
RequestDispatcher
,
ServletContext.getContext(java.lang.String)
,
ServletConfig.getServletName()
public String getRealPath(String path)
getRealPath
in interface ServletContext
path
- The context-relative virtual path to resolveString
specifying the real path, or null if the
translation cannot be performedpublic RequestDispatcher getRequestDispatcher(String path)
getRequestDispatcher
in interface ServletContext
path
- Context-relative path for which to acquire a dispatcherRequestDispatcher
object that acts as a wrapper for
the resource at the specified path, or null
if the
ServletContext
cannot return a
RequestDispatcher
RequestDispatcher
,
ServletContext.getContext(java.lang.String)
public URL getResource(String path) throws MalformedURLException
getResource
in interface ServletContext
path
- Context-relative path of the desired resourcenull
if
there is no resource at that pathMalformedURLException
- if the resource path is
not properly formedpublic InputStream getResourceAsStream(String path)
getResourceAsStream
in interface ServletContext
path
- Context-relative path of the desired resourceInputStream
returned to the servlet, or
null
if no resource exists at the specified pathpublic Set<String> getResourcePaths(String path)
getResourcePaths
in interface ServletContext
path
- Context-relative base pathpublic String getServerInfo()
getServerInfo
in interface ServletContext
String
containing at least the servlet container
name and version number@Deprecated public Servlet getServlet(String name) throws ServletException
getServlet
in interface ServletContext
name
- Name of the requested servletnull
ServletException
- neverpublic String getServletContextName()
getServletContextName
in interface ServletContext
@Deprecated public Enumeration<String> getServletNames()
getServletNames
in interface ServletContext
@Deprecated public Enumeration<Servlet> getServlets()
getServlets
in interface ServletContext
public void log(String message)
log
in interface ServletContext
message
- The message to be logged@Deprecated public void log(Exception exception, String message)
log
in interface ServletContext
exception
- The exception to be loggedmessage
- The message to be loggedpublic void log(String message, Throwable exception)
log
in interface ServletContext
message
- The message to be loggedexception
- The exception to be loggedpublic void removeAttribute(String name)
removeAttribute
in interface ServletContext
name
- Name of the attribute to removepublic void setAttribute(String name, Object value)
setAttribute
in interface ServletContext
name
- Name of the context attribute to setvalue
- Corresponding attribute valuepublic FilterRegistration.Dynamic addFilter(String filterName, String className)
javax.servlet.ServletContext
addFilter
in interface ServletContext
filterName
- Name of filter to addclassName
- Name of filter classnull
if the filter has already been fully defined,
else a FilterRegistration.Dynamic
object
that can be used to further configure the filterpublic ServletRegistration.Dynamic addServlet(String servletName, String className)
javax.servlet.ServletContext
addServlet
in interface ServletContext
servletName
- The name of the servlet to registerclassName
- The implementation class for the servletpublic Set<SessionTrackingMode> getDefaultSessionTrackingModes()
javax.servlet.ServletContext
SessionTrackingMode.URL
is always supported, SessionTrackingMode.COOKIE
is supported unless the cookies
attribute has been set to false
for the context and SessionTrackingMode.SSL
is supported if at least one of the connectors
used by this context has the attribute secure
set to
true
.getDefaultSessionTrackingModes
in interface ServletContext
public Set<SessionTrackingMode> getEffectiveSessionTrackingModes()
javax.servlet.ServletContext
getEffectiveSessionTrackingModes
in interface ServletContext
ServletContext.setSessionTrackingModes(Set)
if
one was previously set, else return the defaultspublic SessionCookieConfig getSessionCookieConfig()
getSessionCookieConfig
in interface ServletContext
public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
javax.servlet.ServletContext
setSessionTrackingModes
in interface ServletContext
sessionTrackingModes
- The session tracking modes to use for this
web applicationpublic FilterRegistration.Dynamic addFilter(String filterName, Filter filter)
javax.servlet.ServletContext
addFilter
in interface ServletContext
filterName
- Name of filter to addfilter
- Filter to addnull
if the filter has already been fully defined,
else a FilterRegistration.Dynamic
object
that can be used to further configure the filterpublic FilterRegistration.Dynamic addFilter(String filterName, Class<? extends Filter> filterClass)
javax.servlet.ServletContext
addFilter
in interface ServletContext
filterName
- Name of filter to addfilterClass
- Class of filter to addnull
if the filter has already been fully defined,
else a FilterRegistration.Dynamic
object
that can be used to further configure the filterpublic ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet)
javax.servlet.ServletContext
addServlet
in interface ServletContext
servletName
- The name of the servlet to registerservlet
- The Servlet instance to registerpublic ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass)
javax.servlet.ServletContext
addServlet
in interface ServletContext
servletName
- Name of servlet to addservletClass
- Class of servlet to addnull
if the servlet has already been fully defined,
else a ServletRegistration.Dynamic
object
that can be used to further configure the servletpublic <T extends Filter> T createFilter(Class<T> c) throws ServletException
javax.servlet.ServletContext
createFilter
in interface ServletContext
T
- TODOc
- TODOServletException
- TODOpublic <T extends Servlet> T createServlet(Class<T> c) throws ServletException
javax.servlet.ServletContext
createServlet
in interface ServletContext
T
- TODOc
- TODOServletException
- TODOpublic FilterRegistration getFilterRegistration(String filterName)
javax.servlet.ServletContext
getFilterRegistration
in interface ServletContext
filterName
- TODOpublic ServletRegistration getServletRegistration(String servletName)
javax.servlet.ServletContext
getServletRegistration
in interface ServletContext
servletName
- The name of the Servlet of interestnull
if no Servlet has been registered with the
given namepublic boolean setInitParameter(String name, String value)
javax.servlet.ServletContext
setInitParameter
in interface ServletContext
name
- Name of initialisation parametervalue
- Value for initialisation parametertrue
if the call succeeds or false
if
the call fails because an initialisation parameter with the same
name has already been setpublic void addListener(Class<? extends EventListener> listenerClass)
javax.servlet.ServletContext
addListener
in interface ServletContext
listenerClass
- TODOpublic void addListener(String className)
javax.servlet.ServletContext
addListener
in interface ServletContext
className
- TODOpublic <T extends EventListener> void addListener(T t)
javax.servlet.ServletContext
addListener
in interface ServletContext
T
- TODOt
- TODOpublic <T extends EventListener> T createListener(Class<T> c) throws ServletException
javax.servlet.ServletContext
createListener
in interface ServletContext
T
- TODOc
- TODOServletException
- TODOpublic void declareRoles(String... roleNames)
javax.servlet.ServletContext
declareRoles
in interface ServletContext
roleNames
- The roles to addpublic ClassLoader getClassLoader()
javax.servlet.ServletContext
getClassLoader
in interface ServletContext
public int getEffectiveMajorVersion()
getEffectiveMajorVersion
in interface ServletContext
public int getEffectiveMinorVersion()
getEffectiveMinorVersion
in interface ServletContext
public Map<String,? extends FilterRegistration> getFilterRegistrations()
getFilterRegistrations
in interface ServletContext
public JspConfigDescriptor getJspConfigDescriptor()
getJspConfigDescriptor
in interface ServletContext
public Map<String,? extends ServletRegistration> getServletRegistrations()
javax.servlet.ServletContext
getServletRegistrations
in interface ServletContext
public String getVirtualServerName()
javax.servlet.ServletContext
getVirtualServerName
in interface ServletContext
Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.