Interface Context

  • All Superinterfaces:
    jakarta.servlet.ServletContext
    All Known Implementing Classes:
    AdHocWebModule, ContextFacade, WebModule

    public interface Context
    extends jakarta.servlet.ServletContext
    Representation of a web application.

    See WebContainer for usage example.

    Author:
    Rajiv Mordani, Jan Luehe
    • Field Summary

      • Fields inherited from interface jakarta.servlet.ServletContext

        ORDERED_LIBS, TEMPDIR
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addListener​(Class<? extends EventListener> c)
      Instantiates a listener from the given class and registers it with this Context.
      <T extends EventListener>
      void
      addListener​(T t)
      Registers the given listener with this Context.
      String getPath()
      Return the context path for this Context.
      SecurityConfig getSecurityConfig()
      Gets the security related configuration for this context
      boolean isDirectoryListing()
      Checks whether directory listings are enabled or disabled on this Context.
      void setDefaultWebXml​(String defaultWebXml)
      Set the location of the default web xml that will be used.
      void setDirectoryListing​(boolean directoryListing)
      Enables or disables directory listings on this Context.
      void setPath​(String path)
      Set the context path for this Context.
      void setSecurityConfig​(SecurityConfig config)
      Set the security related configuration for this context
      • Methods inherited from interface jakarta.servlet.ServletContext

        addFilter, addFilter, addFilter, addJspFile, addListener, addServlet, addServlet, addServlet, createFilter, createListener, createServlet, declareRoles, getAttribute, getAttributeNames, getClassLoader, getContext, getContextPath, getDefaultSessionTrackingModes, getEffectiveMajorVersion, getEffectiveMinorVersion, getEffectiveSessionTrackingModes, getFilterRegistration, getFilterRegistrations, getInitParameter, getInitParameterNames, getJspConfigDescriptor, getMajorVersion, getMimeType, getMinorVersion, getNamedDispatcher, getRealPath, getRequestCharacterEncoding, getRequestDispatcher, getResource, getResourceAsStream, getResourcePaths, getResponseCharacterEncoding, getServerInfo, getServletContextName, getServletRegistration, getServletRegistrations, getSessionCookieConfig, getSessionTimeout, getVirtualServerName, log, log, removeAttribute, setAttribute, setInitParameter, setRequestCharacterEncoding, setResponseCharacterEncoding, setSessionTimeout, setSessionTrackingModes
    • Method Detail

      • addListener

        <T extends EventListener> void addListener​(T t)
        Registers the given listener with this Context.

        The given listener must be an instance of one or more of the following interfaces:

        • jakarta.servlet.ServletContextAttributeListener
        • jakarta.servlet.ServletRequestAttributeListener
        • jakarta.servlet.ServletRequestListener
        • jakarta.servlet.ServletContextListener
        • jakarta.servlet.http.HttpSessionAttributeListener
        • jakarta.servlet.http.HttpSessionIdListener
        • jakarta.servlet.http.HttpSessionListener
        Specified by:
        addListener in interface jakarta.servlet.ServletContext
        Parameters:
        t - the listener to be registered with this Context
        Throws:
        IllegalArgumentException - if the given listener is not an instance of any of the above interfaces
        IllegalStateException - if this context has already been initialized and started
      • addListener

        void addListener​(Class<? extends EventListener> c)
        Instantiates a listener from the given class and registers it with this Context.

        The given listener must be an instance of one or more of the following interfaces:

        • jakarta.servlet.ServletContextAttributeListener
        • jakarta.servlet.ServletRequestAttributeListener
        • jakarta.servlet.ServletRequestListener
        • jakarta.servlet.ServletContextListener
        • jakarta.servlet.http.HttpSessionAttributeListener
        • jakarta.servlet.http.HttpSessionListener
        Specified by:
        addListener in interface jakarta.servlet.ServletContext
        Parameters:
        c - the class from which to instantiate of the listener
        Throws:
        IllegalArgumentException - if the given class does not implement any of the above interfaces
        IllegalStateException - if this context has already been initialized and started
      • setDirectoryListing

        void setDirectoryListing​(boolean directoryListing)
        Enables or disables directory listings on this Context.
        Parameters:
        directoryListing - true if directory listings are to be enabled on this Context, false otherwise
      • isDirectoryListing

        boolean isDirectoryListing()
        Checks whether directory listings are enabled or disabled on this Context.
        Returns:
        true if directory listings are enabled on this Context, false otherwise
      • setSecurityConfig

        void setSecurityConfig​(SecurityConfig config)
        Set the security related configuration for this context
        Parameters:
        config - the security configuration for this context
        See Also:
        SecurityConfig
      • getSecurityConfig

        SecurityConfig getSecurityConfig()
        Gets the security related configuration for this context
        Returns:
        the security configuration for this context
        See Also:
        SecurityConfig
      • setDefaultWebXml

        void setDefaultWebXml​(String defaultWebXml)
        Set the location of the default web xml that will be used.
        Parameters:
        defaultWebXml - the defaultWebXml path to be used
      • getPath

        String getPath()
        Return the context path for this Context.
      • setPath

        void setPath​(String path)
        Set the context path for this Context.