Class JspCServletContext

java.lang.Object
org.apache.jasper.servlet.JspCServletContext
All Implemented Interfaces:
jakarta.servlet.ServletContext

public class JspCServletContext extends Object implements jakarta.servlet.ServletContext
Simple ServletContext implementation without HTTP-specific methods.
Author:
Peter Rossbach (pr@webapp.de)
  • Constructor Details

    • 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 for log() calls
      aResourceBaseURL - Resource base URL
      classLoader - 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?
      Throws:
      JasperException - An error occurred building the merged web.xml
  • Method Details

    • getAttribute

      public Object getAttribute(String name)
      Return the specified context attribute, if any.
      Specified by:
      getAttribute in interface jakarta.servlet.ServletContext
      Parameters:
      name - Name of the requested attribute
    • getAttributeNames

      public Enumeration<String> getAttributeNames()
      Return an enumeration of context attribute names.
      Specified by:
      getAttributeNames in interface jakarta.servlet.ServletContext
    • getContext

      public jakarta.servlet.ServletContext getContext(String uripath)
      Return the servlet context for the specified path.
      Specified by:
      getContext in interface jakarta.servlet.ServletContext
      Parameters:
      uripath - Server-relative path starting with '/'
    • getContextPath

      public String getContextPath()
      Return the context path.
      Specified by:
      getContextPath in interface jakarta.servlet.ServletContext
    • getInitParameter

      public String getInitParameter(String name)
      Return the specified context initialization parameter.
      Specified by:
      getInitParameter in interface jakarta.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:
      getInitParameterNames in interface jakarta.servlet.ServletContext
    • getMajorVersion

      public int getMajorVersion()
      Return the Servlet API major version number.
      Specified by:
      getMajorVersion in interface jakarta.servlet.ServletContext
    • getMimeType

      public String getMimeType(String file)
      Return the MIME type for the specified filename.
      Specified by:
      getMimeType in interface jakarta.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 interface jakarta.servlet.ServletContext
    • getNamedDispatcher

      public jakarta.servlet.RequestDispatcher getNamedDispatcher(String name)
      Return a request dispatcher for the specified servlet name.
      Specified by:
      getNamedDispatcher in interface jakarta.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:
      getRealPath in interface jakarta.servlet.ServletContext
      Parameters:
      path - The context-relative virtual path to resolve
    • getRequestDispatcher

      public jakarta.servlet.RequestDispatcher getRequestDispatcher(String path)
      Return a request dispatcher for the specified context-relative path.
      Specified by:
      getRequestDispatcher in interface jakarta.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:
      getResource in interface jakarta.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:
      getResourceAsStream in interface jakarta.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:
      getResourcePaths in interface jakarta.servlet.ServletContext
      Parameters:
      path - Context-relative base path
    • getServerInfo

      public String getServerInfo()
      Return descriptive information about this server.
      Specified by:
      getServerInfo in interface jakarta.servlet.ServletContext
    • getServletContextName

      public String getServletContextName()
      Return the name of this servlet context.
      Specified by:
      getServletContextName in interface jakarta.servlet.ServletContext
    • log

      public void log(String message)
      Log the specified message.
      Specified by:
      log in interface jakarta.servlet.ServletContext
      Parameters:
      message - The message to be logged
    • log

      public void log(String message, Throwable exception)
      Log the specified message and exception.
      Specified by:
      log in interface jakarta.servlet.ServletContext
      Parameters:
      message - The message to be logged
      exception - The exception to be logged
    • removeAttribute

      public void removeAttribute(String name)
      Remove the specified context attribute.
      Specified by:
      removeAttribute in interface jakarta.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:
      setAttribute in interface jakarta.servlet.ServletContext
      Parameters:
      name - Name of the context attribute to set
      value - Corresponding attribute value
    • addFilter

      public jakarta.servlet.FilterRegistration.Dynamic addFilter(String filterName, String className)
      Specified by:
      addFilter in interface jakarta.servlet.ServletContext
    • addServlet

      public jakarta.servlet.ServletRegistration.Dynamic addServlet(String servletName, String className)
      Specified by:
      addServlet in interface jakarta.servlet.ServletContext
    • getDefaultSessionTrackingModes

      public Set<jakarta.servlet.SessionTrackingMode> getDefaultSessionTrackingModes()
      Specified by:
      getDefaultSessionTrackingModes in interface jakarta.servlet.ServletContext
    • getEffectiveSessionTrackingModes

      public Set<jakarta.servlet.SessionTrackingMode> getEffectiveSessionTrackingModes()
      Specified by:
      getEffectiveSessionTrackingModes in interface jakarta.servlet.ServletContext
    • getSessionCookieConfig

      public jakarta.servlet.SessionCookieConfig getSessionCookieConfig()
      Specified by:
      getSessionCookieConfig in interface jakarta.servlet.ServletContext
    • setSessionTrackingModes

      public void setSessionTrackingModes(Set<jakarta.servlet.SessionTrackingMode> sessionTrackingModes)
      Specified by:
      setSessionTrackingModes in interface jakarta.servlet.ServletContext
    • addFilter

      public jakarta.servlet.FilterRegistration.Dynamic addFilter(String filterName, jakarta.servlet.Filter filter)
      Specified by:
      addFilter in interface jakarta.servlet.ServletContext
    • addFilter

      public jakarta.servlet.FilterRegistration.Dynamic addFilter(String filterName, Class<? extends jakarta.servlet.Filter> filterClass)
      Specified by:
      addFilter in interface jakarta.servlet.ServletContext
    • addServlet

      public jakarta.servlet.ServletRegistration.Dynamic addServlet(String servletName, jakarta.servlet.Servlet servlet)
      Specified by:
      addServlet in interface jakarta.servlet.ServletContext
    • addServlet

      public jakarta.servlet.ServletRegistration.Dynamic addServlet(String servletName, Class<? extends jakarta.servlet.Servlet> servletClass)
      Specified by:
      addServlet in interface jakarta.servlet.ServletContext
    • addJspFile

      public jakarta.servlet.ServletRegistration.Dynamic addJspFile(String jspName, String jspFile)
      Specified by:
      addJspFile in interface jakarta.servlet.ServletContext
    • createFilter

      public <T extends jakarta.servlet.Filter> T createFilter(Class<T> c) throws jakarta.servlet.ServletException
      Specified by:
      createFilter in interface jakarta.servlet.ServletContext
      Throws:
      jakarta.servlet.ServletException
    • createServlet

      public <T extends jakarta.servlet.Servlet> T createServlet(Class<T> c) throws jakarta.servlet.ServletException
      Specified by:
      createServlet in interface jakarta.servlet.ServletContext
      Throws:
      jakarta.servlet.ServletException
    • getFilterRegistration

      public jakarta.servlet.FilterRegistration getFilterRegistration(String filterName)
      Specified by:
      getFilterRegistration in interface jakarta.servlet.ServletContext
    • getServletRegistration

      public jakarta.servlet.ServletRegistration getServletRegistration(String servletName)
      Specified by:
      getServletRegistration in interface jakarta.servlet.ServletContext
    • setInitParameter

      public boolean setInitParameter(String name, String value)
      Specified by:
      setInitParameter in interface jakarta.servlet.ServletContext
    • addListener

      public void addListener(Class<? extends EventListener> listenerClass)
      Specified by:
      addListener in interface jakarta.servlet.ServletContext
    • addListener

      public void addListener(String className)
      Specified by:
      addListener in interface jakarta.servlet.ServletContext
    • addListener

      public <T extends EventListener> void addListener(T t)
      Specified by:
      addListener in interface jakarta.servlet.ServletContext
    • createListener

      public <T extends EventListener> T createListener(Class<T> c) throws jakarta.servlet.ServletException
      Specified by:
      createListener in interface jakarta.servlet.ServletContext
      Throws:
      jakarta.servlet.ServletException
    • declareRoles

      public void declareRoles(String... roleNames)
      Specified by:
      declareRoles in interface jakarta.servlet.ServletContext
    • getClassLoader

      public ClassLoader getClassLoader()
      Specified by:
      getClassLoader in interface jakarta.servlet.ServletContext
    • getEffectiveMajorVersion

      public int getEffectiveMajorVersion()
      Specified by:
      getEffectiveMajorVersion in interface jakarta.servlet.ServletContext
    • getEffectiveMinorVersion

      public int getEffectiveMinorVersion()
      Specified by:
      getEffectiveMinorVersion in interface jakarta.servlet.ServletContext
    • getFilterRegistrations

      public Map<String,? extends jakarta.servlet.FilterRegistration> getFilterRegistrations()
      Specified by:
      getFilterRegistrations in interface jakarta.servlet.ServletContext
    • getJspConfigDescriptor

      public jakarta.servlet.descriptor.JspConfigDescriptor getJspConfigDescriptor()
      Specified by:
      getJspConfigDescriptor in interface jakarta.servlet.ServletContext
    • getServletRegistrations

      public Map<String,? extends jakarta.servlet.ServletRegistration> getServletRegistrations()
      Specified by:
      getServletRegistrations in interface jakarta.servlet.ServletContext
    • getVirtualServerName

      public String getVirtualServerName()
      Specified by:
      getVirtualServerName in interface jakarta.servlet.ServletContext
    • getSessionTimeout

      public int getSessionTimeout()
      Specified by:
      getSessionTimeout in interface jakarta.servlet.ServletContext
    • setSessionTimeout

      public void setSessionTimeout(int sessionTimeout)
      Specified by:
      setSessionTimeout in interface jakarta.servlet.ServletContext
    • getRequestCharacterEncoding

      public String getRequestCharacterEncoding()
      Specified by:
      getRequestCharacterEncoding in interface jakarta.servlet.ServletContext
    • setRequestCharacterEncoding

      public void setRequestCharacterEncoding(String encoding)
      Specified by:
      setRequestCharacterEncoding in interface jakarta.servlet.ServletContext
    • getResponseCharacterEncoding

      public String getResponseCharacterEncoding()
      Specified by:
      getResponseCharacterEncoding in interface jakarta.servlet.ServletContext
    • setResponseCharacterEncoding

      public void setResponseCharacterEncoding(String encoding)
      Specified by:
      setResponseCharacterEncoding in interface jakarta.servlet.ServletContext