org.apache.struts2.jasper.servlet

## Class JspCServletContext

- java.lang.Object
- - org.apache.struts2.jasper.servlet.JspCServletContext

- All Implemented Interfaces:
    javax.servlet.ServletContext

      public class JspCServletContext
      extends Object
      implements javax.servlet.ServletContext

  Simple `ServletContext` implementation without HTTP-specific methods.
  Author:
    Peter Rossbach (pr@webapp.de)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Hashtable` | `myAttributes` Servlet context attributes.
    `protected PrintWriter` | `myLogWriter` The log writer we will write log messages to.

    - ### Fields inherited from interface javax.servlet.ServletContext

      `ORDERED_LIBS, TEMPDIR`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JspCServletContext(PrintWriter aLogWriter, ClassLoaderInterface classLoaderInterface)` Create a new instance of this ServletContext implementation.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `javax.servlet.FilterRegistration.Dynamic` | `addFilter(String arg0, Class<? extends javax.servlet.Filter> arg1)`
    `javax.servlet.FilterRegistration.Dynamic` | `addFilter(String arg0, javax.servlet.Filter arg1)`
    `javax.servlet.FilterRegistration.Dynamic` | `addFilter(String arg0, String arg1)`
    `void` | `addListener(Class<? extends EventListener> arg0)`
    `void` | `addListener(String arg0)`
    `<T extends EventListener> void` | `addListener(T arg0)`
    `javax.servlet.ServletRegistration.Dynamic` | `addServlet(String arg0, Class<? extends javax.servlet.Servlet> arg1)`
    `javax.servlet.ServletRegistration.Dynamic` | `addServlet(String arg0, javax.servlet.Servlet arg1)`
    `javax.servlet.ServletRegistration.Dynamic` | `addServlet(String arg0, String arg1)`
    `<T extends javax.servlet.Filter> T` | `createFilter(Class<T> arg0)`
    `<T extends EventListener> T` | `createListener(Class<T> arg0)`
    `<T extends javax.servlet.Servlet> T` | `createServlet(Class<T> arg0)`
    `void` | `declareRoles(String... arg0)`
    `Object` | `getAttribute(String name)`
    `Enumeration` | `getAttributeNames()`
    `ClassLoader` | `getClassLoader()`
    `javax.servlet.ServletContext` | `getContext(String uripath)`
    `String` | `getContextPath()`
    `Set<javax.servlet.SessionTrackingMode>` | `getDefaultSessionTrackingModes()`
    `int` | `getEffectiveMajorVersion()`
    `int` | `getEffectiveMinorVersion()`
    `Set<javax.servlet.SessionTrackingMode>` | `getEffectiveSessionTrackingModes()`
    `javax.servlet.FilterRegistration` | `getFilterRegistration(String arg0)`
    `Map<String,? extends javax.servlet.FilterRegistration>` | `getFilterRegistrations()`
    `String` | `getInitParameter(String name)`
    `Enumeration` | `getInitParameterNames()`
    `javax.servlet.descriptor.JspConfigDescriptor` | `getJspConfigDescriptor()`
    `int` | `getMajorVersion()`
    `String` | `getMimeType(String file)`
    `int` | `getMinorVersion()`
    `javax.servlet.RequestDispatcher` | `getNamedDispatcher(String name)`
    `String` | `getRealPath(String path)`
    `javax.servlet.RequestDispatcher` | `getRequestDispatcher(String path)`
    `URL` | `getResource(String path)`
    `InputStream` | `getResourceAsStream(String path)`
    `Set` | `getResourcePaths(String path)`
    `String` | `getServerInfo()`
    `javax.servlet.Servlet` | `getServlet(String name)` Deprecated. This method has been deprecated with no replacement
    `String` | `getServletContextName()`
    `Enumeration` | `getServletNames()` Deprecated. This method has been deprecated with no replacement
    `javax.servlet.ServletRegistration` | `getServletRegistration(String arg0)`
    `Map<String,? extends javax.servlet.ServletRegistration>` | `getServletRegistrations()`
    `Enumeration` | `getServlets()` Deprecated. This method has been deprecated with no replacement
    `javax.servlet.SessionCookieConfig` | `getSessionCookieConfig()`
    `String` | `getVirtualServerName()`
    `void` | `log(Exception exception, String message)` Deprecated. Use log(String,Throwable) instead
    `void` | `log(String message)` Log the specified message.
    `void` | `log(String message, Throwable exception)` Log the specified message and exception.
    `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 arg0, String arg1)`
    `void` | `setSessionTrackingModes(Set<javax.servlet.SessionTrackingMode> arg0)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### myAttributes

          protected Hashtable myAttributes

      Servlet context attributes.

    - #### myLogWriter

          protected PrintWriter myLogWriter

      The log writer we will write log messages to.

  - ### Constructor Detail

    - #### JspCServletContext

          public JspCServletContext(PrintWriter aLogWriter,
                                    ClassLoaderInterface classLoaderInterface)

      Create a new instance of this ServletContext implementation.
      Parameters:
        `aLogWriter` - PrintWriter which is used for `log()` calls
        `classLoaderInterface` - classloader interface

  - ### Method Detail

    - #### getAttribute

          public Object getAttribute(String name)

      Specified by:
        `getAttribute` in interface `javax.servlet.ServletContext`
      Parameters:
        `name` - Name of the requested attribute
      Returns:
        the specified context attribute, if any.

    - #### getAttributeNames

          public Enumeration getAttributeNames()

      Specified by:
        `getAttributeNames` in interface `javax.servlet.ServletContext`
      Returns:
        an enumeration of context attribute names.

    - #### getContext

          public javax.servlet.ServletContext getContext(String uripath)

      Specified by:
        `getContext` in interface `javax.servlet.ServletContext`
      Parameters:
        `uripath` - Server-relative path starting with '/'
      Returns:
        the servlet context for the specified path.

    - #### getContextPath

          public String getContextPath()

      Specified by:
        `getContextPath` in interface `javax.servlet.ServletContext`
      Returns:
        the context path.

    - #### getInitParameter

          public String getInitParameter(String name)

      Specified by:
        `getInitParameter` in interface `javax.servlet.ServletContext`
      Parameters:
        `name` - Name of the requested parameter
      Returns:
        the specified context initialization parameter.

    - #### getInitParameterNames

          public Enumeration getInitParameterNames()

      Specified by:
        `getInitParameterNames` in interface `javax.servlet.ServletContext`
      Returns:
        an enumeration of the names of context initialization parameters.

    - #### getMajorVersion

          public int getMajorVersion()

      Specified by:
        `getMajorVersion` in interface `javax.servlet.ServletContext`
      Returns:
        the Servlet API major version number.

    - #### getMimeType

          public String getMimeType(String file)

      Specified by:
        `getMimeType` in interface `javax.servlet.ServletContext`
      Parameters:
        `file` - Filename whose MIME type is requested
      Returns:
        the MIME type for the specified filename.

    - #### getMinorVersion

          public int getMinorVersion()

      Specified by:
        `getMinorVersion` in interface `javax.servlet.ServletContext`
      Returns:
        the Servlet API minor version number.

    - #### getNamedDispatcher

          public javax.servlet.RequestDispatcher getNamedDispatcher(String name)

      Specified by:
        `getNamedDispatcher` in interface `javax.servlet.ServletContext`
      Parameters:
        `name` - Name of the requested servlet
      Returns:
        a request dispatcher for the specified servlet name.

    - #### getRealPath

          public String getRealPath(String path)

      Specified by:
        `getRealPath` in interface `javax.servlet.ServletContext`
      Parameters:
        `path` - The context-relative virtual path to resolve
      Returns:
        the real path for the specified context-relative virtual path.

    - #### getRequestDispatcher

          public javax.servlet.RequestDispatcher getRequestDispatcher(String path)

      Specified by:
        `getRequestDispatcher` in interface `javax.servlet.ServletContext`
      Parameters:
        `path` - Context-relative path for which to acquire a dispatcher
      Returns:
        a request dispatcher for the specified context-relative path.

    - #### getResource

          public URL getResource(String path)
                          throws MalformedURLException

      Specified by:
        `getResource` in interface `javax.servlet.ServletContext`
      Parameters:
        `path` - Context-relative path of the desired resource
      Returns:
        a URL object of a resource that is mapped to the specified context-relative path.
      Throws:
        `MalformedURLException` - if the resource path is not properly formed

    - #### getResourceAsStream

          public InputStream getResourceAsStream(String path)

      Specified by:
        `getResourceAsStream` in interface `javax.servlet.ServletContext`
      Parameters:
        `path` - Context-relative path of the desired resource
      Returns:
        an InputStream allowing access to the resource at the specified context-relative path.

    - #### getResourcePaths

          public Set getResourcePaths(String path)

      Specified by:
        `getResourcePaths` in interface `javax.servlet.ServletContext`
      Parameters:
        `path` - Context-relative base path
      Returns:
        the set of resource paths for the "directory" at the specified context path.

    - #### getServerInfo

          public String getServerInfo()

      Specified by:
        `getServerInfo` in interface `javax.servlet.ServletContext`
      Returns:
        descriptive information about this server.

    - #### getServlet

          public javax.servlet.Servlet getServlet(String name)
                                           throws javax.servlet.ServletException

      Deprecated. This method has been deprecated with no replacement
      Specified by:
        `getServlet` in interface `javax.servlet.ServletContext`
      Parameters:
        `name` - Name of the requested servlet
      Returns:
        a null reference for the specified servlet name.
      Throws:
        `javax.servlet.ServletException`

    - #### getServletContextName

          public String getServletContextName()

      Specified by:
        `getServletContextName` in interface `javax.servlet.ServletContext`
      Returns:
        the name of this servlet context.

    - #### getServletNames

          public Enumeration getServletNames()

      Deprecated. This method has been deprecated with no replacement
      Specified by:
        `getServletNames` in interface `javax.servlet.ServletContext`
      Returns:
        an empty enumeration of servlet names.

    - #### getServlets

          public Enumeration getServlets()

      Deprecated. This method has been deprecated with no replacement
      Specified by:
        `getServlets` in interface `javax.servlet.ServletContext`
      Returns:
        an empty enumeration of servlets.

    - #### log

          public void log(String message)

      Log the specified message.
      Specified by:
        `log` in interface `javax.servlet.ServletContext`
      Parameters:
        `message` - The message to be logged

    - #### log

          public void log(Exception exception,
                          String message)

      Deprecated. Use log(String,Throwable) instead
      Log the specified message and exception.
      Specified by:
        `log` in interface `javax.servlet.ServletContext`
      Parameters:
        `exception` - The exception to be logged
        `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 `javax.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 `javax.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 `javax.servlet.ServletContext`
      Parameters:
        `name` - Name of the context attribute to set
        `value` - Corresponding attribute value

    - #### getEffectiveMajorVersion

          public int getEffectiveMajorVersion()

      Specified by:
        `getEffectiveMajorVersion` in interface `javax.servlet.ServletContext`

    - #### getEffectiveMinorVersion

          public int getEffectiveMinorVersion()

      Specified by:
        `getEffectiveMinorVersion` in interface `javax.servlet.ServletContext`

    - #### setInitParameter

          public boolean setInitParameter(String arg0,
                                          String arg1)

      Specified by:
        `setInitParameter` in interface `javax.servlet.ServletContext`

    - #### addServlet

          public javax.servlet.ServletRegistration.Dynamic addServlet(String arg0,
                                                                      String arg1)

      Specified by:
        `addServlet` in interface `javax.servlet.ServletContext`

    - #### addServlet

          public javax.servlet.ServletRegistration.Dynamic addServlet(String arg0,
                                                                      javax.servlet.Servlet arg1)

      Specified by:
        `addServlet` in interface `javax.servlet.ServletContext`

    - #### addServlet

          public javax.servlet.ServletRegistration.Dynamic addServlet(String arg0,
                                                                      Class<? extends javax.servlet.Servlet> arg1)

      Specified by:
        `addServlet` in interface `javax.servlet.ServletContext`

    - #### createServlet

          public <T extends javax.servlet.Servlet> T createServlet(Class<T> arg0)
                                                            throws javax.servlet.ServletException

      Specified by:
        `createServlet` in interface `javax.servlet.ServletContext`
      Throws:
        `javax.servlet.ServletException`

    - #### getServletRegistration

          public javax.servlet.ServletRegistration getServletRegistration(String arg0)

      Specified by:
        `getServletRegistration` in interface `javax.servlet.ServletContext`

    - #### getServletRegistrations

          public Map<String,? extends javax.servlet.ServletRegistration> getServletRegistrations()

      Specified by:
        `getServletRegistrations` in interface `javax.servlet.ServletContext`

    - #### addFilter

          public javax.servlet.FilterRegistration.Dynamic addFilter(String arg0,
                                                                    String arg1)

      Specified by:
        `addFilter` in interface `javax.servlet.ServletContext`

    - #### addFilter

          public javax.servlet.FilterRegistration.Dynamic addFilter(String arg0,
                                                                    javax.servlet.Filter arg1)

      Specified by:
        `addFilter` in interface `javax.servlet.ServletContext`

    - #### addFilter

          public javax.servlet.FilterRegistration.Dynamic addFilter(String arg0,
                                                                    Class<? extends javax.servlet.Filter> arg1)

      Specified by:
        `addFilter` in interface `javax.servlet.ServletContext`

    - #### createFilter

          public <T extends javax.servlet.Filter> T createFilter(Class<T> arg0)
                                                          throws javax.servlet.ServletException

      Specified by:
        `createFilter` in interface `javax.servlet.ServletContext`
      Throws:
        `javax.servlet.ServletException`

    - #### getFilterRegistration

          public javax.servlet.FilterRegistration getFilterRegistration(String arg0)

      Specified by:
        `getFilterRegistration` in interface `javax.servlet.ServletContext`

    - #### getFilterRegistrations

          public Map<String,? extends javax.servlet.FilterRegistration> getFilterRegistrations()

      Specified by:
        `getFilterRegistrations` in interface `javax.servlet.ServletContext`

    - #### getSessionCookieConfig

          public javax.servlet.SessionCookieConfig getSessionCookieConfig()

      Specified by:
        `getSessionCookieConfig` in interface `javax.servlet.ServletContext`

    - #### setSessionTrackingModes

          public void setSessionTrackingModes(Set<javax.servlet.SessionTrackingMode> arg0)

      Specified by:
        `setSessionTrackingModes` in interface `javax.servlet.ServletContext`

    - #### getDefaultSessionTrackingModes

          public Set<javax.servlet.SessionTrackingMode> getDefaultSessionTrackingModes()

      Specified by:
        `getDefaultSessionTrackingModes` in interface `javax.servlet.ServletContext`

    - #### getEffectiveSessionTrackingModes

          public Set<javax.servlet.SessionTrackingMode> getEffectiveSessionTrackingModes()

      Specified by:
        `getEffectiveSessionTrackingModes` in interface `javax.servlet.ServletContext`

    - #### addListener

          public void addListener(String arg0)

      Specified by:
        `addListener` in interface `javax.servlet.ServletContext`

    - #### addListener

          public <T extends EventListener> void addListener(T arg0)

      Specified by:
        `addListener` in interface `javax.servlet.ServletContext`

    - #### addListener

          public void addListener(Class<? extends EventListener> arg0)

      Specified by:
        `addListener` in interface `javax.servlet.ServletContext`

    - #### createListener

          public <T extends EventListener> T createListener(Class<T> arg0)
                                                     throws javax.servlet.ServletException

      Specified by:
        `createListener` in interface `javax.servlet.ServletContext`
      Throws:
        `javax.servlet.ServletException`

    - #### getJspConfigDescriptor

          public javax.servlet.descriptor.JspConfigDescriptor getJspConfigDescriptor()

      Specified by:
        `getJspConfigDescriptor` in interface `javax.servlet.ServletContext`

    - #### getClassLoader

          public ClassLoader getClassLoader()

      Specified by:
        `getClassLoader` in interface `javax.servlet.ServletContext`

    - #### declareRoles

          public void declareRoles(String... arg0)

      Specified by:
        `declareRoles` in interface `javax.servlet.ServletContext`

    - #### getVirtualServerName

          public String getVirtualServerName()

      Specified by:
        `getVirtualServerName` in interface `javax.servlet.ServletContext`

Copyright © 2000–2023 Apache Software Foundation. All rights reserved.