Package org.apache.jasper.servlet
Class JspCServletContext
- java.lang.Object
-
- org.apache.jasper.servlet.JspCServletContext
-
- All Implemented Interfaces:
ServletContext
public class JspCServletContext extends Object implements ServletContext
SimpleServletContextimplementation without HTTP-specific methods.- Author:
- Peter Rossbach (pr@webapp.de)
-
-
Field Summary
-
Fields inherited from interface javax.servlet.ServletContext
ORDERED_LIBS, TEMPDIR
-
-
Constructor Summary
Constructors Constructor Description JspCServletContext(PrintWriter aLogWriter, URL aResourceBaseURL, ClassLoader classLoader, boolean validate, boolean blockExternal)Create a new instance of this ServletContext implementation.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description FilterRegistration.DynamicaddFilter(String filterName, Class<? extends Filter> filterClass)FilterRegistration.DynamicaddFilter(String filterName, String className)FilterRegistration.DynamicaddFilter(String filterName, Filter filter)voidaddListener(Class<? extends EventListener> listenerClass)voidaddListener(String className)<T extends EventListener>
voidaddListener(T t)ServletRegistration.DynamicaddServlet(String servletName, Class<? extends Servlet> servletClass)ServletRegistration.DynamicaddServlet(String servletName, String className)ServletRegistration.DynamicaddServlet(String servletName, Servlet servlet)<T extends Filter>
TcreateFilter(Class<T> c)<T extends EventListener>
TcreateListener(Class<T> c)<T extends 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()ServletContextgetContext(String uripath)Return the servlet context for the specified path.StringgetContextPath()Return the context path.Set<SessionTrackingMode>getDefaultSessionTrackingModes()intgetEffectiveMajorVersion()intgetEffectiveMinorVersion()Set<SessionTrackingMode>getEffectiveSessionTrackingModes()FilterRegistrationgetFilterRegistration(String filterName)Map<String,? extends FilterRegistration>getFilterRegistrations()StringgetInitParameter(String name)Return the specified context initialization parameter.Enumeration<String>getInitParameterNames()Return an enumeration of the names of context initialization parameters.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.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.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.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 replacementServletRegistrationgetServletRegistration(String servletName)Map<String,? extends ServletRegistration>getServletRegistrations()Enumeration<Servlet>getServlets()Deprecated.This method has been deprecated with no replacementSessionCookieConfiggetSessionCookieConfig()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<SessionTrackingMode> sessionTrackingModes)
-
-
-
Constructor Detail
-
JspCServletContext
public JspCServletContext(PrintWriter aLogWriter, URL aResourceBaseURL, ClassLoader classLoader, boolean validate, boolean blockExternal) throws JasperException
Create a new instance of this ServletContext implementation.- Parameters:
aLogWriter- PrintWriter which is used forlog()callsaResourceBaseURL- Resource base URLclassLoader- Class loader for thisServletContextvalidate- Should a validating parser be used to parse web.xml?blockExternal- Should external entities be blocked when parsing web.xml?- Throws:
JasperException- An error occurred building the merged web.xml
-
-
Method Detail
-
getAttribute
public Object getAttribute(String name)
Return the specified context attribute, if any.- Specified by:
getAttributein interfaceServletContext- Parameters:
name- Name of the requested attribute
-
getAttributeNames
public Enumeration<String> getAttributeNames()
Return an enumeration of context attribute names.- Specified by:
getAttributeNamesin interfaceServletContext
-
getContext
public ServletContext getContext(String uripath)
Return the servlet context for the specified path.- Specified by:
getContextin interfaceServletContext- Parameters:
uripath- Server-relative path starting with '/'
-
getContextPath
public String getContextPath()
Return the context path.- Specified by:
getContextPathin interfaceServletContext
-
getInitParameter
public String getInitParameter(String name)
Return the specified context initialization parameter.- Specified by:
getInitParameterin interfaceServletContext- 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 interfaceServletContext
-
getMajorVersion
public int getMajorVersion()
Return the Servlet API major version number.- Specified by:
getMajorVersionin interfaceServletContext
-
getMimeType
public String getMimeType(String file)
Return the MIME type for the specified filename.- Specified by:
getMimeTypein interfaceServletContext- Parameters:
file- Filename whose MIME type is requested
-
getMinorVersion
public int getMinorVersion()
Return the Servlet API minor version number.- Specified by:
getMinorVersionin interfaceServletContext
-
getNamedDispatcher
public RequestDispatcher getNamedDispatcher(String name)
Return a request dispatcher for the specified servlet name.- Specified by:
getNamedDispatcherin interfaceServletContext- 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 interfaceServletContext- Parameters:
path- The context-relative virtual path to resolve
-
getRequestDispatcher
public RequestDispatcher getRequestDispatcher(String path)
Return a request dispatcher for the specified context-relative path.- Specified by:
getRequestDispatcherin interfaceServletContext- 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 interfaceServletContext- 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 interfaceServletContext- 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 interfaceServletContext- Parameters:
path- Context-relative base path
-
getServerInfo
public String getServerInfo()
Return descriptive information about this server.- Specified by:
getServerInfoin interfaceServletContext
-
getServlet
@Deprecated public Servlet getServlet(String name) throws ServletException
Deprecated.This method has been deprecated with no replacementReturn a null reference for the specified servlet name.- Specified by:
getServletin interfaceServletContext- Parameters:
name- Name of the requested servlet- Throws:
ServletException
-
getServletContextName
public String getServletContextName()
Return the name of this servlet context.- Specified by:
getServletContextNamein interfaceServletContext
-
getServletNames
@Deprecated public Enumeration<String> getServletNames()
Deprecated.This method has been deprecated with no replacementReturn an empty enumeration of servlet names.- Specified by:
getServletNamesin interfaceServletContext
-
getServlets
@Deprecated public Enumeration<Servlet> getServlets()
Deprecated.This method has been deprecated with no replacementReturn an empty enumeration of servlets.- Specified by:
getServletsin interfaceServletContext
-
log
public void log(String message)
Log the specified message.- Specified by:
login interfaceServletContext- Parameters:
message- The message to be logged
-
log
@Deprecated public void log(Exception exception, String message)
Deprecated.Use log(String,Throwable) insteadLog the specified message and exception.- Specified by:
login interfaceServletContext- 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 interfaceServletContext- 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 interfaceServletContext- 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 interfaceServletContext- Parameters:
name- Name of the context attribute to setvalue- Corresponding attribute value
-
addFilter
public FilterRegistration.Dynamic addFilter(String filterName, String className)
- Specified by:
addFilterin interfaceServletContext
-
addServlet
public ServletRegistration.Dynamic addServlet(String servletName, String className)
- Specified by:
addServletin interfaceServletContext
-
getDefaultSessionTrackingModes
public Set<SessionTrackingMode> getDefaultSessionTrackingModes()
- Specified by:
getDefaultSessionTrackingModesin interfaceServletContext
-
getEffectiveSessionTrackingModes
public Set<SessionTrackingMode> getEffectiveSessionTrackingModes()
- Specified by:
getEffectiveSessionTrackingModesin interfaceServletContext
-
getSessionCookieConfig
public SessionCookieConfig getSessionCookieConfig()
- Specified by:
getSessionCookieConfigin interfaceServletContext
-
setSessionTrackingModes
public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
- Specified by:
setSessionTrackingModesin interfaceServletContext
-
addFilter
public FilterRegistration.Dynamic addFilter(String filterName, Filter filter)
- Specified by:
addFilterin interfaceServletContext
-
addFilter
public FilterRegistration.Dynamic addFilter(String filterName, Class<? extends Filter> filterClass)
- Specified by:
addFilterin interfaceServletContext
-
addServlet
public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet)
- Specified by:
addServletin interfaceServletContext
-
addServlet
public ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass)
- Specified by:
addServletin interfaceServletContext
-
createFilter
public <T extends Filter> T createFilter(Class<T> c) throws ServletException
- Specified by:
createFilterin interfaceServletContext- Throws:
ServletException
-
createServlet
public <T extends Servlet> T createServlet(Class<T> c) throws ServletException
- Specified by:
createServletin interfaceServletContext- Throws:
ServletException
-
getFilterRegistration
public FilterRegistration getFilterRegistration(String filterName)
- Specified by:
getFilterRegistrationin interfaceServletContext
-
getServletRegistration
public ServletRegistration getServletRegistration(String servletName)
- Specified by:
getServletRegistrationin interfaceServletContext
-
setInitParameter
public boolean setInitParameter(String name, String value)
- Specified by:
setInitParameterin interfaceServletContext
-
addListener
public void addListener(Class<? extends EventListener> listenerClass)
- Specified by:
addListenerin interfaceServletContext
-
addListener
public void addListener(String className)
- Specified by:
addListenerin interfaceServletContext
-
addListener
public <T extends EventListener> void addListener(T t)
- Specified by:
addListenerin interfaceServletContext
-
createListener
public <T extends EventListener> T createListener(Class<T> c) throws ServletException
- Specified by:
createListenerin interfaceServletContext- Throws:
ServletException
-
declareRoles
public void declareRoles(String... roleNames)
- Specified by:
declareRolesin interfaceServletContext
-
getClassLoader
public ClassLoader getClassLoader()
- Specified by:
getClassLoaderin interfaceServletContext
-
getEffectiveMajorVersion
public int getEffectiveMajorVersion()
- Specified by:
getEffectiveMajorVersionin interfaceServletContext
-
getEffectiveMinorVersion
public int getEffectiveMinorVersion()
- Specified by:
getEffectiveMinorVersionin interfaceServletContext
-
getFilterRegistrations
public Map<String,? extends FilterRegistration> getFilterRegistrations()
- Specified by:
getFilterRegistrationsin interfaceServletContext
-
getJspConfigDescriptor
public JspConfigDescriptor getJspConfigDescriptor()
- Specified by:
getJspConfigDescriptorin interfaceServletContext
-
getServletRegistrations
public Map<String,? extends ServletRegistration> getServletRegistrations()
- Specified by:
getServletRegistrationsin interfaceServletContext
-
getVirtualServerName
public String getVirtualServerName()
- Specified by:
getVirtualServerNamein interfaceServletContext
-
-