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 Object implements javax.servlet.ServletContext
SimpleServletContextimplementation without HTTP-specific methods.- Author:
- Peter Rossbach (pr@webapp.de)
-
-
Field Summary
Fields Modifier and Type Field Description protected Hashtable<String,Object>myAttributesServlet context attributes.protected PrintWritermyLogWriterThe log writer we will write log messages to.protected URLmyResourceBaseURLThe base URL (document root) for this context.
-
Constructor Summary
Constructors Constructor Description JspCServletContext(PrintWriter aLogWriter, 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.DynamicaddFilter(String filterName, Class<? extends javax.servlet.Filter> filterClass)javax.servlet.FilterRegistration.DynamicaddFilter(String filterName, String className)voidaddFilter(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.DynamicaddFilter(String filterName, javax.servlet.Filter filter)voidaddListener(Class<? extends EventListener> listenerClass)voidaddListener(String className)<T extends EventListener>
voidaddListener(T t)javax.servlet.ServletRegistration.DynamicaddServlet(String servletName, Class<? extends javax.servlet.Servlet> servletClass)javax.servlet.ServletRegistration.DynamicaddServlet(String servletName, String className)voidaddServlet(String servletName, String description, String className, Map<String,String> initParameters, int loadOnStartup)javax.servlet.ServletRegistration.DynamicaddServlet(String servletName, javax.servlet.Servlet servlet)voidaddServletMapping(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)voiddeclareRoles(String... roleNames)ObjectgetAttribute(String name)Return the specified context attribute, if any.Enumeration<String>getAttributeNames()Return an enumeration of context attribute names.ClassLoadergetClassLoader()javax.servlet.ServletContextgetContext(String uripath)Return the servlet context for the specified path.StringgetContextPath()Returns the context path of the web application.Set<javax.servlet.SessionTrackingMode>getDefaultSessionTrackingModes()intgetEffectiveMajorVersion()intgetEffectiveMinorVersion()Set<javax.servlet.SessionTrackingMode>getEffectiveSessionTrackingModes()javax.servlet.FilterRegistrationgetFilterRegistration(String filterName)Map<String,javax.servlet.FilterRegistration>getFilterRegistrations()StringgetInitParameter(String name)Return the specified context initialization parameter.Enumeration<String>getInitParameterNames()Return an enumeration of the names of context initialization parameters.javax.servlet.descriptor.JspConfigDescriptorgetJspConfigDescriptor()intgetMajorVersion()Return the Servlet API major version number.StringgetMimeType(String file)Return the MIME type for the specified filename.intgetMinorVersion()Return the Servlet API minor version number.javax.servlet.RequestDispatchergetNamedDispatcher(String name)Return a request dispatcher for the specified servlet name.StringgetRealPath(String path)Return the real path for the specified context-relative virtual path.javax.servlet.RequestDispatchergetRequestDispatcher(String path)Return a request dispatcher for the specified context-relative path.URLgetResource(String path)Return a URL object of a resource that is mapped to the specified context-relative path.InputStreamgetResourceAsStream(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.StringgetServerInfo()Return descriptive information about this server.javax.servlet.ServletgetServlet(String name)Deprecated.This method has been deprecated with no replacementStringgetServletContextName()Return the name of this servlet context.Enumeration<String>getServletNames()Deprecated.This method has been deprecated with no replacementjavax.servlet.ServletRegistrationgetServletRegistration(String servletName)Map<String,javax.servlet.ServletRegistration>getServletRegistrations()Enumeration<javax.servlet.Servlet>getServlets()Deprecated.This method has been deprecated with no replacementjavax.servlet.SessionCookieConfiggetSessionCookieConfig()StringgetVirtualServerName()voidlog(Exception exception, String message)Deprecated.Use log(String,Throwable) insteadvoidlog(String message)Log the specified message.voidlog(String message, Throwable exception)Log the specified message and exception.voidremoveAttribute(String name)Remove the specified context attribute.voidsetAttribute(String name, Object value)Set or replace the specified context attribute.booleansetInitParameter(String name, String value)voidsetSessionTrackingModes(Set<javax.servlet.SessionTrackingMode> sessionTrackingModes)
-
-
-
Field Detail
-
myLogWriter
protected PrintWriter myLogWriter
The log writer we will write log messages to.
-
myResourceBaseURL
protected URL myResourceBaseURL
The base URL (document root) for this context.
-
-
Constructor Detail
-
JspCServletContext
public JspCServletContext(PrintWriter aLogWriter, URL aResourceBaseURL)
Create a new instance of this ServletContext implementation.- Parameters:
aLogWriter- PrintWriter which is used forlog()callsaResourceBaseURL- Resource base URL
-
-
Method Detail
-
getAttribute
public Object getAttribute(String name)
Return the specified context attribute, if any.- Specified by:
getAttributein interfacejavax.servlet.ServletContext- Parameters:
name- Name of the requested attribute
-
getAttributeNames
public Enumeration<String> getAttributeNames()
Return an enumeration of context attribute names.- Specified by:
getAttributeNamesin interfacejavax.servlet.ServletContext
-
getContextPath
public String getContextPath()
Returns the context path of the web application.- Specified by:
getContextPathin interfacejavax.servlet.ServletContext
-
getContext
public javax.servlet.ServletContext getContext(String uripath)
Return the servlet context for the specified path.- Specified by:
getContextin interfacejavax.servlet.ServletContext- Parameters:
uripath- Server-relative path starting with '/'
-
getInitParameter
public String getInitParameter(String name)
Return the specified context initialization parameter.- Specified by:
getInitParameterin interfacejavax.servlet.ServletContext- Parameters:
name- Name of the requested parameter
-
getInitParameterNames
public Enumeration<String> getInitParameterNames()
Return an enumeration of the names of context initialization parameters.- Specified by:
getInitParameterNamesin interfacejavax.servlet.ServletContext
-
getMajorVersion
public int getMajorVersion()
Return the Servlet API major version number.- Specified by:
getMajorVersionin interfacejavax.servlet.ServletContext
-
getMimeType
public String getMimeType(String file)
Return the MIME type for the specified filename.- Specified by:
getMimeTypein interfacejavax.servlet.ServletContext- Parameters:
file- Filename whose MIME type is requested
-
getMinorVersion
public int getMinorVersion()
Return the Servlet API minor version number.- Specified by:
getMinorVersionin interfacejavax.servlet.ServletContext
-
getEffectiveMajorVersion
public int getEffectiveMajorVersion()
- Specified by:
getEffectiveMajorVersionin interfacejavax.servlet.ServletContext
-
getEffectiveMinorVersion
public int getEffectiveMinorVersion()
- Specified by:
getEffectiveMinorVersionin interfacejavax.servlet.ServletContext
-
getNamedDispatcher
public javax.servlet.RequestDispatcher getNamedDispatcher(String name)
Return a request dispatcher for the specified servlet name.- Specified by:
getNamedDispatcherin interfacejavax.servlet.ServletContext- Parameters:
name- Name of the requested servlet
-
getRealPath
public String getRealPath(String path)
Return the real path for the specified context-relative virtual path.- Specified by:
getRealPathin interfacejavax.servlet.ServletContext- Parameters:
path- The context-relative virtual path to resolve
-
getRequestDispatcher
public javax.servlet.RequestDispatcher getRequestDispatcher(String path)
Return a request dispatcher for the specified context-relative path.- Specified by:
getRequestDispatcherin interfacejavax.servlet.ServletContext- Parameters:
path- Context-relative path for which to acquire a dispatcher
-
getResource
public URL getResource(String path) throws MalformedURLException
Return a URL object of a resource that is mapped to the specified context-relative path.- Specified by:
getResourcein interfacejavax.servlet.ServletContext- Parameters:
path- Context-relative path of the desired resource- Throws:
MalformedURLException- if the resource path is not properly formed
-
getResourceAsStream
public InputStream getResourceAsStream(String path)
Return an InputStream allowing access to the resource at the specified context-relative path.- Specified by:
getResourceAsStreamin interfacejavax.servlet.ServletContext- Parameters:
path- Context-relative path of the desired resource
-
getResourcePaths
public Set<String> getResourcePaths(String path)
Return the set of resource paths for the "directory" at the specified context path.- Specified by:
getResourcePathsin interfacejavax.servlet.ServletContext- Parameters:
path- Context-relative base path
-
getServerInfo
public String getServerInfo()
Return descriptive information about this server.- Specified by:
getServerInfoin interfacejavax.servlet.ServletContext
-
getServlet
public javax.servlet.Servlet getServlet(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:
getServletin interfacejavax.servlet.ServletContext- Parameters:
name- Name of the requested servlet- Throws:
javax.servlet.ServletException
-
getServletContextName
public String getServletContextName()
Return the name of this servlet context.- Specified by:
getServletContextNamein interfacejavax.servlet.ServletContext
-
getServletNames
public Enumeration<String> getServletNames()
Deprecated.This method has been deprecated with no replacementReturn an empty enumeration of servlet names.- Specified by:
getServletNamesin interfacejavax.servlet.ServletContext
-
getServlets
public Enumeration<javax.servlet.Servlet> getServlets()
Deprecated.This method has been deprecated with no replacementReturn an empty enumeration of servlets.- Specified by:
getServletsin interfacejavax.servlet.ServletContext
-
log
public void log(String message)
Log the specified message.- Specified by:
login interfacejavax.servlet.ServletContext- Parameters:
message- The message to be logged
-
log
public void log(Exception exception, String message)
Deprecated.Use log(String,Throwable) insteadLog the specified message and exception.- Specified by:
login interfacejavax.servlet.ServletContext- Parameters:
exception- The exception to be loggedmessage- The message to be logged
-
log
public void log(String message, Throwable exception)
Log the specified message and exception.- Specified by:
login interfacejavax.servlet.ServletContext- Parameters:
message- The message to be loggedexception- The exception to be logged
-
removeAttribute
public void removeAttribute(String name)
Remove the specified context attribute.- Specified by:
removeAttributein interfacejavax.servlet.ServletContext- Parameters:
name- Name of the attribute to remove
-
setAttribute
public void setAttribute(String name, Object value)
Set or replace the specified context attribute.- Specified by:
setAttributein interfacejavax.servlet.ServletContext- Parameters:
name- Name of the context attribute to setvalue- Corresponding attribute value
-
addServlet
public void addServlet(String servletName, String description, String className, Map<String,String> initParameters, int loadOnStartup)
-
addServletMapping
public 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.
-
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
public boolean setInitParameter(String name, String value)
- Specified by:
setInitParameterin interfacejavax.servlet.ServletContext
-
addServlet
public javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, String className)
- Specified by:
addServletin interfacejavax.servlet.ServletContext
-
addServlet
public javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, javax.servlet.Servlet servlet)
- Specified by:
addServletin interfacejavax.servlet.ServletContext
-
addServlet
public javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, Class<? extends javax.servlet.Servlet> servletClass)
- Specified by:
addServletin interfacejavax.servlet.ServletContext
-
createServlet
public <T extends javax.servlet.Servlet> T createServlet(Class<T> c) throws javax.servlet.ServletException
- Specified by:
createServletin interfacejavax.servlet.ServletContext- Throws:
javax.servlet.ServletException
-
getServletRegistration
public javax.servlet.ServletRegistration getServletRegistration(String servletName)
- Specified by:
getServletRegistrationin interfacejavax.servlet.ServletContext
-
getServletRegistrations
public Map<String,javax.servlet.ServletRegistration> getServletRegistrations()
- Specified by:
getServletRegistrationsin interfacejavax.servlet.ServletContext
-
addFilter
public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, String className)
- Specified by:
addFilterin interfacejavax.servlet.ServletContext
-
addFilter
public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, javax.servlet.Filter filter)
- Specified by:
addFilterin interfacejavax.servlet.ServletContext
-
addFilter
public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, Class<? extends javax.servlet.Filter> filterClass)
- Specified by:
addFilterin interfacejavax.servlet.ServletContext
-
createFilter
public <T extends javax.servlet.Filter> T createFilter(Class<T> c)
- Specified by:
createFilterin interfacejavax.servlet.ServletContext
-
getFilterRegistration
public javax.servlet.FilterRegistration getFilterRegistration(String filterName)
- Specified by:
getFilterRegistrationin interfacejavax.servlet.ServletContext
-
getFilterRegistrations
public Map<String,javax.servlet.FilterRegistration> getFilterRegistrations()
- Specified by:
getFilterRegistrationsin interfacejavax.servlet.ServletContext
-
getSessionCookieConfig
public javax.servlet.SessionCookieConfig getSessionCookieConfig()
- Specified by:
getSessionCookieConfigin interfacejavax.servlet.ServletContext
-
setSessionTrackingModes
public void setSessionTrackingModes(Set<javax.servlet.SessionTrackingMode> sessionTrackingModes)
- Specified by:
setSessionTrackingModesin interfacejavax.servlet.ServletContext
-
getDefaultSessionTrackingModes
public Set<javax.servlet.SessionTrackingMode> getDefaultSessionTrackingModes()
- Specified by:
getDefaultSessionTrackingModesin interfacejavax.servlet.ServletContext
-
getEffectiveSessionTrackingModes
public Set<javax.servlet.SessionTrackingMode> getEffectiveSessionTrackingModes()
- Specified by:
getEffectiveSessionTrackingModesin interfacejavax.servlet.ServletContext
-
addListener
public void addListener(String className)
- Specified by:
addListenerin interfacejavax.servlet.ServletContext
-
addListener
public <T extends EventListener> void addListener(T t)
- Specified by:
addListenerin interfacejavax.servlet.ServletContext
-
addListener
public void addListener(Class<? extends EventListener> listenerClass)
- Specified by:
addListenerin interfacejavax.servlet.ServletContext
-
createListener
public <T extends EventListener> T createListener(Class<T> clazz) throws javax.servlet.ServletException
- Specified by:
createListenerin interfacejavax.servlet.ServletContext- Throws:
javax.servlet.ServletException
-
getJspConfigDescriptor
public javax.servlet.descriptor.JspConfigDescriptor getJspConfigDescriptor()
- Specified by:
getJspConfigDescriptorin interfacejavax.servlet.ServletContext
-
getClassLoader
public ClassLoader getClassLoader()
- Specified by:
getClassLoaderin interfacejavax.servlet.ServletContext
-
declareRoles
public void declareRoles(String... roleNames)
- Specified by:
declareRolesin interfacejavax.servlet.ServletContext
-
getVirtualServerName
public String getVirtualServerName()
- Specified by:
getVirtualServerNamein interfacejavax.servlet.ServletContext
-
-