Package org.apache.jasper.servlet
Class JspCServletContext
- java.lang.Object
-
- org.apache.jasper.servlet.JspCServletContext
-
- All Implemented Interfaces:
javax.servlet.ServletContext
public class JspCServletContext extends java.lang.Object implements javax.servlet.ServletContext
SimpleServletContext
implementation without HTTP-specific methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
JspCServletContext.JspConfigDescriptorImpl
(package private) static class
JspCServletContext.JspPropertyGroupDescriptorImpl
(package private) static class
JspCServletContext.TaglibDescriptorImpl
-
Field Summary
Fields Modifier and Type Field Description private javax.servlet.descriptor.JspConfigDescriptor
jspConfigDescriptor
protected java.util.Hashtable<java.lang.String,java.lang.Object>
myAttributes
Servlet context attributes.protected java.io.PrintWriter
myLogWriter
The log writer we will write log messages to.protected java.net.URL
myResourceBaseURL
The base URL (document root) for this context.private static java.lang.String
WEB_XML
-
Constructor Summary
Constructors Constructor Description JspCServletContext(java.io.PrintWriter aLogWriter, java.net.URL aResourceBaseURL)
Create a new instance of this ServletContext implementation.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description javax.servlet.FilterRegistration.Dynamic
addFilter(java.lang.String filterName, java.lang.Class<? extends javax.servlet.Filter> filterClass)
javax.servlet.FilterRegistration.Dynamic
addFilter(java.lang.String filterName, java.lang.String className)
void
addFilter(java.lang.String filterName, java.lang.String description, java.lang.String className, java.util.Map<java.lang.String,java.lang.String> initParameters)
Adds the filter with the given name, description, and class name to this servlet context.javax.servlet.FilterRegistration.Dynamic
addFilter(java.lang.String filterName, javax.servlet.Filter filter)
javax.servlet.ServletRegistration.Dynamic
addJspFile(java.lang.String servletName, java.lang.String jspFile)
void
addListener(java.lang.Class<? extends java.util.EventListener> listenerClass)
void
addListener(java.lang.String className)
<T extends java.util.EventListener>
voidaddListener(T t)
javax.servlet.ServletRegistration.Dynamic
addServlet(java.lang.String servletName, java.lang.Class<? extends javax.servlet.Servlet> servletClass)
javax.servlet.ServletRegistration.Dynamic
addServlet(java.lang.String servletName, java.lang.String className)
void
addServlet(java.lang.String servletName, java.lang.String description, java.lang.String className, java.util.Map<java.lang.String,java.lang.String> initParameters, int loadOnStartup)
javax.servlet.ServletRegistration.Dynamic
addServlet(java.lang.String servletName, javax.servlet.Servlet servlet)
void
addServletMapping(java.lang.String servletName, java.lang.String[] urlPatterns)
Adds servlet mappings from the given url patterns to the servlet with the given servlet name to this servlet context.<T extends javax.servlet.Filter>
TcreateFilter(java.lang.Class<T> c)
<T extends java.util.EventListener>
TcreateListener(java.lang.Class<T> clazz)
<T extends javax.servlet.Servlet>
TcreateServlet(java.lang.Class<T> c)
void
declareRoles(java.lang.String... roleNames)
java.lang.Object
getAttribute(java.lang.String name)
Return the specified context attribute, if any.java.util.Enumeration<java.lang.String>
getAttributeNames()
Return an enumeration of context attribute names.java.lang.ClassLoader
getClassLoader()
javax.servlet.ServletContext
getContext(java.lang.String uripath)
Return the servlet context for the specified path.java.lang.String
getContextPath()
Returns the context path of the web application.java.util.Set<javax.servlet.SessionTrackingMode>
getDefaultSessionTrackingModes()
int
getEffectiveMajorVersion()
int
getEffectiveMinorVersion()
java.util.Set<javax.servlet.SessionTrackingMode>
getEffectiveSessionTrackingModes()
javax.servlet.FilterRegistration
getFilterRegistration(java.lang.String filterName)
java.util.Map<java.lang.String,javax.servlet.FilterRegistration>
getFilterRegistrations()
java.lang.String
getInitParameter(java.lang.String name)
Return the specified context initialization parameter.java.util.Enumeration<java.lang.String>
getInitParameterNames()
Return an enumeration of the names of context initialization parameters.javax.servlet.descriptor.JspConfigDescriptor
getJspConfigDescriptor()
int
getMajorVersion()
Return the Servlet API major version number.java.lang.String
getMimeType(java.lang.String file)
Return the MIME type for the specified filename.int
getMinorVersion()
Return the Servlet API minor version number.javax.servlet.RequestDispatcher
getNamedDispatcher(java.lang.String name)
Return a request dispatcher for the specified servlet name.java.lang.String
getRealPath(java.lang.String path)
Return the real path for the specified context-relative virtual path.java.lang.String
getRequestCharacterEncoding()
javax.servlet.RequestDispatcher
getRequestDispatcher(java.lang.String path)
Return a request dispatcher for the specified context-relative path.java.net.URL
getResource(java.lang.String path)
Return a URL object of a resource that is mapped to the specified context-relative path.java.io.InputStream
getResourceAsStream(java.lang.String path)
Return an InputStream allowing access to the resource at the specified context-relative path.java.util.Set<java.lang.String>
getResourcePaths(java.lang.String path)
Return the set of resource paths for the "directory" at the specified context path.java.lang.String
getResponseCharacterEncoding()
java.lang.String
getServerInfo()
Return descriptive information about this server.javax.servlet.Servlet
getServlet(java.lang.String name)
Deprecated.This method has been deprecated with no replacementjava.lang.String
getServletContextName()
Return the name of this servlet context.java.util.Enumeration<java.lang.String>
getServletNames()
Deprecated.This method has been deprecated with no replacementjavax.servlet.ServletRegistration
getServletRegistration(java.lang.String servletName)
java.util.Map<java.lang.String,javax.servlet.ServletRegistration>
getServletRegistrations()
java.util.Enumeration<javax.servlet.Servlet>
getServlets()
Deprecated.This method has been deprecated with no replacementjavax.servlet.SessionCookieConfig
getSessionCookieConfig()
int
getSessionTimeout()
java.lang.String
getVirtualServerName()
void
log(java.lang.Exception exception, java.lang.String message)
Deprecated.Use log(String,Throwable) insteadvoid
log(java.lang.String message)
Log the specified message.void
log(java.lang.String message, java.lang.Throwable exception)
Log the specified message and exception.private void
parseWebDotXml()
void
removeAttribute(java.lang.String name)
Remove the specified context attribute.void
setAttribute(java.lang.String name, java.lang.Object value)
Set or replace the specified context attribute.boolean
setInitParameter(java.lang.String name, java.lang.String value)
void
setRequestCharacterEncoding(java.lang.String charset)
void
setResponseCharacterEncoding(java.lang.String charset)
void
setSessionTimeout(int sessionTimeout)
void
setSessionTrackingModes(java.util.Set<javax.servlet.SessionTrackingMode> sessionTrackingModes)
-
-
-
Field Detail
-
myAttributes
protected java.util.Hashtable<java.lang.String,java.lang.Object> myAttributes
Servlet context attributes.
-
myLogWriter
protected java.io.PrintWriter myLogWriter
The log writer we will write log messages to.
-
myResourceBaseURL
protected java.net.URL myResourceBaseURL
The base URL (document root) for this context.
-
jspConfigDescriptor
private javax.servlet.descriptor.JspConfigDescriptor jspConfigDescriptor
-
WEB_XML
private static final java.lang.String WEB_XML
- See Also:
- Constant Field Values
-
-
Method Detail
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
Return the specified context attribute, if any.- Specified by:
getAttribute
in interfacejavax.servlet.ServletContext
- Parameters:
name
- Name of the requested attribute
-
getAttributeNames
public java.util.Enumeration<java.lang.String> getAttributeNames()
Return an enumeration of context attribute names.- Specified by:
getAttributeNames
in interfacejavax.servlet.ServletContext
-
getContextPath
public java.lang.String getContextPath()
Returns the context path of the web application.- Specified by:
getContextPath
in interfacejavax.servlet.ServletContext
-
getContext
public javax.servlet.ServletContext getContext(java.lang.String uripath)
Return the servlet context for the specified path.- Specified by:
getContext
in interfacejavax.servlet.ServletContext
- Parameters:
uripath
- Server-relative path starting with '/'
-
getInitParameter
public java.lang.String getInitParameter(java.lang.String name)
Return the specified context initialization parameter.- Specified by:
getInitParameter
in interfacejavax.servlet.ServletContext
- Parameters:
name
- Name of the requested parameter
-
getInitParameterNames
public java.util.Enumeration<java.lang.String> getInitParameterNames()
Return an enumeration of the names of context initialization parameters.- Specified by:
getInitParameterNames
in interfacejavax.servlet.ServletContext
-
getMajorVersion
public int getMajorVersion()
Return the Servlet API major version number.- Specified by:
getMajorVersion
in interfacejavax.servlet.ServletContext
-
getMimeType
public java.lang.String getMimeType(java.lang.String file)
Return the MIME type for the specified filename.- Specified by:
getMimeType
in interfacejavax.servlet.ServletContext
- Parameters:
file
- Filename whose MIME type is requested
-
getMinorVersion
public int getMinorVersion()
Return the Servlet API minor version number.- Specified by:
getMinorVersion
in interfacejavax.servlet.ServletContext
-
getEffectiveMajorVersion
public int getEffectiveMajorVersion()
- Specified by:
getEffectiveMajorVersion
in interfacejavax.servlet.ServletContext
-
getEffectiveMinorVersion
public int getEffectiveMinorVersion()
- Specified by:
getEffectiveMinorVersion
in interfacejavax.servlet.ServletContext
-
getNamedDispatcher
public javax.servlet.RequestDispatcher getNamedDispatcher(java.lang.String name)
Return a request dispatcher for the specified servlet name.- Specified by:
getNamedDispatcher
in interfacejavax.servlet.ServletContext
- Parameters:
name
- Name of the requested servlet
-
getRealPath
public java.lang.String getRealPath(java.lang.String path)
Return the real path for the specified context-relative virtual path.- Specified by:
getRealPath
in interfacejavax.servlet.ServletContext
- Parameters:
path
- The context-relative virtual path to resolve
-
getRequestDispatcher
public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path)
Return a request dispatcher for the specified context-relative path.- Specified by:
getRequestDispatcher
in interfacejavax.servlet.ServletContext
- Parameters:
path
- Context-relative path for which to acquire a dispatcher
-
getResource
public java.net.URL getResource(java.lang.String path) throws java.net.MalformedURLException
Return a URL object of a resource that is mapped to the specified context-relative path.- Specified by:
getResource
in interfacejavax.servlet.ServletContext
- Parameters:
path
- Context-relative path of the desired resource- Throws:
java.net.MalformedURLException
- if the resource path is not properly formed
-
getResourceAsStream
public java.io.InputStream getResourceAsStream(java.lang.String path)
Return an InputStream allowing access to the resource at the specified context-relative path.- Specified by:
getResourceAsStream
in interfacejavax.servlet.ServletContext
- Parameters:
path
- Context-relative path of the desired resource
-
getResourcePaths
public java.util.Set<java.lang.String> getResourcePaths(java.lang.String path)
Return the set of resource paths for the "directory" at the specified context path.- Specified by:
getResourcePaths
in interfacejavax.servlet.ServletContext
- Parameters:
path
- Context-relative base path
-
getServerInfo
public java.lang.String getServerInfo()
Return descriptive information about this server.- Specified by:
getServerInfo
in interfacejavax.servlet.ServletContext
-
getServlet
public javax.servlet.Servlet getServlet(java.lang.String name) throws javax.servlet.ServletException
Deprecated.This method has been deprecated with no replacementReturn a null reference for the specified servlet name.- Specified by:
getServlet
in interfacejavax.servlet.ServletContext
- Parameters:
name
- Name of the requested servlet- Throws:
javax.servlet.ServletException
-
getServletContextName
public java.lang.String getServletContextName()
Return the name of this servlet context.- Specified by:
getServletContextName
in interfacejavax.servlet.ServletContext
-
getServletNames
public java.util.Enumeration<java.lang.String> getServletNames()
Deprecated.This method has been deprecated with no replacementReturn an empty enumeration of servlet names.- Specified by:
getServletNames
in interfacejavax.servlet.ServletContext
-
getServlets
public java.util.Enumeration<javax.servlet.Servlet> getServlets()
Deprecated.This method has been deprecated with no replacementReturn an empty enumeration of servlets.- Specified by:
getServlets
in interfacejavax.servlet.ServletContext
-
log
public void log(java.lang.String message)
Log the specified message.- Specified by:
log
in interfacejavax.servlet.ServletContext
- Parameters:
message
- The message to be logged
-
log
public void log(java.lang.Exception exception, java.lang.String message)
Deprecated.Use log(String,Throwable) insteadLog the specified message and exception.- Specified by:
log
in interfacejavax.servlet.ServletContext
- Parameters:
exception
- The exception to be loggedmessage
- The message to be logged
-
log
public void log(java.lang.String message, java.lang.Throwable exception)
Log the specified message and exception.- Specified by:
log
in interfacejavax.servlet.ServletContext
- Parameters:
message
- The message to be loggedexception
- The exception to be logged
-
removeAttribute
public void removeAttribute(java.lang.String name)
Remove the specified context attribute.- Specified by:
removeAttribute
in interfacejavax.servlet.ServletContext
- Parameters:
name
- Name of the attribute to remove
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)
Set or replace the specified context attribute.- Specified by:
setAttribute
in interfacejavax.servlet.ServletContext
- Parameters:
name
- Name of the context attribute to setvalue
- Corresponding attribute value
-
addServlet
public void addServlet(java.lang.String servletName, java.lang.String description, java.lang.String className, java.util.Map<java.lang.String,java.lang.String> initParameters, int loadOnStartup)
-
addServletMapping
public void addServletMapping(java.lang.String servletName, java.lang.String[] urlPatterns)
Adds servlet mappings from the given url patterns to the servlet with the given servlet name to this servlet context.
-
addFilter
public void addFilter(java.lang.String filterName, java.lang.String description, java.lang.String className, java.util.Map<java.lang.String,java.lang.String> initParameters)
Adds the filter with the given name, description, and class name to this servlet context.
-
setInitParameter
public boolean setInitParameter(java.lang.String name, java.lang.String value)
- Specified by:
setInitParameter
in interfacejavax.servlet.ServletContext
-
addServlet
public javax.servlet.ServletRegistration.Dynamic addServlet(java.lang.String servletName, java.lang.String className)
- Specified by:
addServlet
in interfacejavax.servlet.ServletContext
-
addServlet
public javax.servlet.ServletRegistration.Dynamic addServlet(java.lang.String servletName, javax.servlet.Servlet servlet)
- Specified by:
addServlet
in interfacejavax.servlet.ServletContext
-
addServlet
public javax.servlet.ServletRegistration.Dynamic addServlet(java.lang.String servletName, java.lang.Class<? extends javax.servlet.Servlet> servletClass)
- Specified by:
addServlet
in interfacejavax.servlet.ServletContext
-
createServlet
public <T extends javax.servlet.Servlet> T createServlet(java.lang.Class<T> c) throws javax.servlet.ServletException
- Specified by:
createServlet
in interfacejavax.servlet.ServletContext
- Throws:
javax.servlet.ServletException
-
getServletRegistration
public javax.servlet.ServletRegistration getServletRegistration(java.lang.String servletName)
- Specified by:
getServletRegistration
in interfacejavax.servlet.ServletContext
-
getServletRegistrations
public java.util.Map<java.lang.String,javax.servlet.ServletRegistration> getServletRegistrations()
- Specified by:
getServletRegistrations
in interfacejavax.servlet.ServletContext
-
addFilter
public javax.servlet.FilterRegistration.Dynamic addFilter(java.lang.String filterName, java.lang.String className)
- Specified by:
addFilter
in interfacejavax.servlet.ServletContext
-
addFilter
public javax.servlet.FilterRegistration.Dynamic addFilter(java.lang.String filterName, javax.servlet.Filter filter)
- Specified by:
addFilter
in interfacejavax.servlet.ServletContext
-
addFilter
public javax.servlet.FilterRegistration.Dynamic addFilter(java.lang.String filterName, java.lang.Class<? extends javax.servlet.Filter> filterClass)
- Specified by:
addFilter
in interfacejavax.servlet.ServletContext
-
createFilter
public <T extends javax.servlet.Filter> T createFilter(java.lang.Class<T> c)
- Specified by:
createFilter
in interfacejavax.servlet.ServletContext
-
getFilterRegistration
public javax.servlet.FilterRegistration getFilterRegistration(java.lang.String filterName)
- Specified by:
getFilterRegistration
in interfacejavax.servlet.ServletContext
-
getFilterRegistrations
public java.util.Map<java.lang.String,javax.servlet.FilterRegistration> getFilterRegistrations()
- Specified by:
getFilterRegistrations
in interfacejavax.servlet.ServletContext
-
getSessionCookieConfig
public javax.servlet.SessionCookieConfig getSessionCookieConfig()
- Specified by:
getSessionCookieConfig
in interfacejavax.servlet.ServletContext
-
setSessionTrackingModes
public void setSessionTrackingModes(java.util.Set<javax.servlet.SessionTrackingMode> sessionTrackingModes)
- Specified by:
setSessionTrackingModes
in interfacejavax.servlet.ServletContext
-
getDefaultSessionTrackingModes
public java.util.Set<javax.servlet.SessionTrackingMode> getDefaultSessionTrackingModes()
- Specified by:
getDefaultSessionTrackingModes
in interfacejavax.servlet.ServletContext
-
getEffectiveSessionTrackingModes
public java.util.Set<javax.servlet.SessionTrackingMode> getEffectiveSessionTrackingModes()
- Specified by:
getEffectiveSessionTrackingModes
in interfacejavax.servlet.ServletContext
-
addListener
public void addListener(java.lang.String className)
- Specified by:
addListener
in interfacejavax.servlet.ServletContext
-
addListener
public <T extends java.util.EventListener> void addListener(T t)
- Specified by:
addListener
in interfacejavax.servlet.ServletContext
-
addListener
public void addListener(java.lang.Class<? extends java.util.EventListener> listenerClass)
- Specified by:
addListener
in interfacejavax.servlet.ServletContext
-
createListener
public <T extends java.util.EventListener> T createListener(java.lang.Class<T> clazz) throws javax.servlet.ServletException
- Specified by:
createListener
in interfacejavax.servlet.ServletContext
- Throws:
javax.servlet.ServletException
-
getJspConfigDescriptor
public javax.servlet.descriptor.JspConfigDescriptor getJspConfigDescriptor()
- Specified by:
getJspConfigDescriptor
in interfacejavax.servlet.ServletContext
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
- Specified by:
getClassLoader
in interfacejavax.servlet.ServletContext
-
declareRoles
public void declareRoles(java.lang.String... roleNames)
- Specified by:
declareRoles
in interfacejavax.servlet.ServletContext
-
parseWebDotXml
private void parseWebDotXml()
-
getVirtualServerName
public java.lang.String getVirtualServerName()
- Specified by:
getVirtualServerName
in interfacejavax.servlet.ServletContext
-
setResponseCharacterEncoding
public void setResponseCharacterEncoding(java.lang.String charset)
- Specified by:
setResponseCharacterEncoding
in interfacejavax.servlet.ServletContext
-
getResponseCharacterEncoding
public java.lang.String getResponseCharacterEncoding()
- Specified by:
getResponseCharacterEncoding
in interfacejavax.servlet.ServletContext
-
setRequestCharacterEncoding
public void setRequestCharacterEncoding(java.lang.String charset)
- Specified by:
setRequestCharacterEncoding
in interfacejavax.servlet.ServletContext
-
getRequestCharacterEncoding
public java.lang.String getRequestCharacterEncoding()
- Specified by:
getRequestCharacterEncoding
in interfacejavax.servlet.ServletContext
-
setSessionTimeout
public void setSessionTimeout(int sessionTimeout)
- Specified by:
setSessionTimeout
in interfacejavax.servlet.ServletContext
-
getSessionTimeout
public int getSessionTimeout()
- Specified by:
getSessionTimeout
in interfacejavax.servlet.ServletContext
-
addJspFile
public javax.servlet.ServletRegistration.Dynamic addJspFile(java.lang.String servletName, java.lang.String jspFile)
- Specified by:
addJspFile
in interfacejavax.servlet.ServletContext
-
-