Package org.apache.jasper.servlet
Class JspCServletContext
java.lang.Object
org.apache.jasper.servlet.JspCServletContext
- All Implemented Interfaces:
javax.servlet.ServletContext
Simple
ServletContext
implementation without
HTTP-specific methods.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
(package private) static class
(package private) static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate javax.servlet.descriptor.JspConfigDescriptor
Servlet context attributes.protected PrintWriter
The log writer we will write log messages to.protected URL
The base URL (document root) for this context.private static final String
Fields inherited from interface javax.servlet.ServletContext
ORDERED_LIBS, TEMPDIR
-
Constructor Summary
ConstructorsConstructorDescriptionJspCServletContext
(PrintWriter aLogWriter, URL aResourceBaseURL) Create a new instance of this ServletContext implementation. -
Method Summary
Modifier and TypeMethodDescriptionjavax.servlet.FilterRegistration.Dynamic
javax.servlet.FilterRegistration.Dynamic
void
addFilter
(String filterName, String description, String className, Map<String, String> initParameters) Adds the filter with the given name, description, and class name to this servlet context.javax.servlet.FilterRegistration.Dynamic
javax.servlet.ServletRegistration.Dynamic
addJspFile
(String servletName, String jspFile) void
addListener
(Class<? extends EventListener> listenerClass) void
addListener
(String className) <T extends EventListener>
voidaddListener
(T t) javax.servlet.ServletRegistration.Dynamic
addServlet
(String servletName, Class<? extends javax.servlet.Servlet> servletClass) javax.servlet.ServletRegistration.Dynamic
addServlet
(String servletName, String className) void
addServlet
(String servletName, String description, String className, Map<String, String> initParameters, int loadOnStartup) javax.servlet.ServletRegistration.Dynamic
addServlet
(String servletName, javax.servlet.Servlet servlet) void
addServletMapping
(String servletName, 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
(Class<T> c) <T extends EventListener>
TcreateListener
(Class<T> clazz) <T extends javax.servlet.Servlet>
TcreateServlet
(Class<T> c) void
declareRoles
(String... roleNames) getAttribute
(String name) Return the specified context attribute, if any.Return an enumeration of context attribute names.javax.servlet.ServletContext
getContext
(String uripath) Return the servlet context for the specified path.Returns the context path of the web application.Set
<javax.servlet.SessionTrackingMode> int
int
Set
<javax.servlet.SessionTrackingMode> javax.servlet.FilterRegistration
getFilterRegistration
(String filterName) getInitParameter
(String name) Return the specified context initialization parameter.Return an enumeration of the names of context initialization parameters.javax.servlet.descriptor.JspConfigDescriptor
int
Return the Servlet API major version number.getMimeType
(String file) Return the MIME type for the specified filename.int
Return the Servlet API minor version number.javax.servlet.RequestDispatcher
getNamedDispatcher
(String name) Return a request dispatcher for the specified servlet name.getRealPath
(String path) Return the real path for the specified context-relative virtual path.javax.servlet.RequestDispatcher
getRequestDispatcher
(String path) Return a request dispatcher for the specified context-relative path.getResource
(String path) Return a URL object of a resource that is mapped to the specified context-relative path.getResourceAsStream
(String path) Return an InputStream allowing access to the resource at the specified context-relative path.getResourcePaths
(String path) Return the set of resource paths for the "directory" at the specified context path.Return descriptive information about this server.javax.servlet.Servlet
getServlet
(String name) Deprecated.This method has been deprecated with no replacementReturn the name of this servlet context.Deprecated.This method has been deprecated with no replacementjavax.servlet.ServletRegistration
getServletRegistration
(String servletName) Enumeration
<javax.servlet.Servlet> Deprecated.This method has been deprecated with no replacementjavax.servlet.SessionCookieConfig
int
void
Deprecated.Use log(String,Throwable) insteadvoid
Log the specified message.void
Log the specified message and exception.private void
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) void
setRequestCharacterEncoding
(String charset) void
setResponseCharacterEncoding
(String charset) void
setSessionTimeout
(int sessionTimeout) void
setSessionTrackingModes
(Set<javax.servlet.SessionTrackingMode> sessionTrackingModes)
-
Field Details
-
myAttributes
Servlet context attributes. -
myLogWriter
The log writer we will write log messages to. -
myResourceBaseURL
The base URL (document root) for this context. -
jspConfigDescriptor
private javax.servlet.descriptor.JspConfigDescriptor jspConfigDescriptor -
WEB_XML
- See Also:
-
-
Constructor Details
-
JspCServletContext
Create a new instance of this ServletContext implementation.- Parameters:
aLogWriter
- PrintWriter which is used forlog()
callsaResourceBaseURL
- Resource base URL
-
-
Method Details
-
getAttribute
Return the specified context attribute, if any.- Specified by:
getAttribute
in interfacejavax.servlet.ServletContext
- Parameters:
name
- Name of the requested attribute
-
getAttributeNames
Return an enumeration of context attribute names.- Specified by:
getAttributeNames
in interfacejavax.servlet.ServletContext
-
getContextPath
Returns the context path of the web application.- Specified by:
getContextPath
in interfacejavax.servlet.ServletContext
-
getContext
Return the servlet context for the specified path.- Specified by:
getContext
in interfacejavax.servlet.ServletContext
- Parameters:
uripath
- Server-relative path starting with '/'
-
getInitParameter
Return the specified context initialization parameter.- Specified by:
getInitParameter
in interfacejavax.servlet.ServletContext
- Parameters:
name
- Name of the requested parameter
-
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
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
Return a request dispatcher for the specified servlet name.- Specified by:
getNamedDispatcher
in interfacejavax.servlet.ServletContext
- Parameters:
name
- Name of the requested servlet
-
getRealPath
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
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
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:
MalformedURLException
- if the resource path is not properly formed
-
getResourceAsStream
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
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
Return descriptive information about this server.- Specified by:
getServerInfo
in interfacejavax.servlet.ServletContext
-
getServlet
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
Return the name of this servlet context.- Specified by:
getServletContextName
in interfacejavax.servlet.ServletContext
-
getServletNames
Deprecated.This method has been deprecated with no replacementReturn an empty enumeration of servlet names.- Specified by:
getServletNames
in interfacejavax.servlet.ServletContext
-
getServlets
Deprecated.This method has been deprecated with no replacementReturn an empty enumeration of servlets.- Specified by:
getServlets
in interfacejavax.servlet.ServletContext
-
log
Log the specified message.- Specified by:
log
in interfacejavax.servlet.ServletContext
- Parameters:
message
- The message to be logged
-
log
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
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
Remove the specified context attribute.- Specified by:
removeAttribute
in interfacejavax.servlet.ServletContext
- Parameters:
name
- Name of the attribute to remove
-
setAttribute
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
-
addServletMapping
Adds servlet mappings from the given url patterns to the servlet with the given servlet name to this servlet context. -
addFilter
public void addFilter(String filterName, String description, String className, Map<String, String> initParameters) Adds the filter with the given name, description, and class name to this servlet context. -
setInitParameter
- Specified by:
setInitParameter
in interfacejavax.servlet.ServletContext
-
addServlet
- Specified by:
addServlet
in interfacejavax.servlet.ServletContext
-
addServlet
public javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, javax.servlet.Servlet servlet) - Specified by:
addServlet
in interfacejavax.servlet.ServletContext
-
addServlet
public javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, Class<? extends javax.servlet.Servlet> servletClass) - Specified by:
addServlet
in interfacejavax.servlet.ServletContext
-
createServlet
public <T extends javax.servlet.Servlet> T createServlet(Class<T> c) throws javax.servlet.ServletException - Specified by:
createServlet
in interfacejavax.servlet.ServletContext
- Throws:
javax.servlet.ServletException
-
getServletRegistration
- Specified by:
getServletRegistration
in interfacejavax.servlet.ServletContext
-
getServletRegistrations
- Specified by:
getServletRegistrations
in interfacejavax.servlet.ServletContext
-
addFilter
- Specified by:
addFilter
in interfacejavax.servlet.ServletContext
-
addFilter
public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, javax.servlet.Filter filter) - Specified by:
addFilter
in interfacejavax.servlet.ServletContext
-
addFilter
public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, Class<? extends javax.servlet.Filter> filterClass) - Specified by:
addFilter
in interfacejavax.servlet.ServletContext
-
createFilter
- Specified by:
createFilter
in interfacejavax.servlet.ServletContext
-
getFilterRegistration
- Specified by:
getFilterRegistration
in interfacejavax.servlet.ServletContext
-
getFilterRegistrations
- Specified by:
getFilterRegistrations
in interfacejavax.servlet.ServletContext
-
getSessionCookieConfig
public javax.servlet.SessionCookieConfig getSessionCookieConfig()- Specified by:
getSessionCookieConfig
in interfacejavax.servlet.ServletContext
-
setSessionTrackingModes
- Specified by:
setSessionTrackingModes
in interfacejavax.servlet.ServletContext
-
getDefaultSessionTrackingModes
- Specified by:
getDefaultSessionTrackingModes
in interfacejavax.servlet.ServletContext
-
getEffectiveSessionTrackingModes
- Specified by:
getEffectiveSessionTrackingModes
in interfacejavax.servlet.ServletContext
-
addListener
- Specified by:
addListener
in interfacejavax.servlet.ServletContext
-
addListener
- Specified by:
addListener
in interfacejavax.servlet.ServletContext
-
addListener
- Specified by:
addListener
in interfacejavax.servlet.ServletContext
-
createListener
public <T extends EventListener> T createListener(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
- Specified by:
getClassLoader
in interfacejavax.servlet.ServletContext
-
declareRoles
- Specified by:
declareRoles
in interfacejavax.servlet.ServletContext
-
parseWebDotXml
private void parseWebDotXml() -
getVirtualServerName
- Specified by:
getVirtualServerName
in interfacejavax.servlet.ServletContext
-
setResponseCharacterEncoding
- Specified by:
setResponseCharacterEncoding
in interfacejavax.servlet.ServletContext
-
getResponseCharacterEncoding
- Specified by:
getResponseCharacterEncoding
in interfacejavax.servlet.ServletContext
-
setRequestCharacterEncoding
- Specified by:
setRequestCharacterEncoding
in interfacejavax.servlet.ServletContext
-
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
- Specified by:
addJspFile
in interfacejavax.servlet.ServletContext
-