FilterRegistration (Servlet 6.0 API Documentation - Apache Tomcat 10.1.7)

Package jakarta.servlet

## Interface FilterRegistration

- All Superinterfaces:
    `Registration`
  All Known Subinterfaces:
    `FilterRegistration.Dynamic`

      public interface FilterRegistration
      extends Registration

  Interface through which a Filter may be further configured.
  Since:
    Servlet 3.0

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface | Description
    --- | --- | ---
    `static interface` | `FilterRegistration.Dynamic` | Interface through which a Filter registered via one of the addFilter methods on ServletContext may be further configured.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addMappingForServletNames​(java.util.EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter, java.lang.String... servletNames)` | Add a mapping for this filter to one or more named Servlets.
    `void` | `addMappingForUrlPatterns​(java.util.EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter, java.lang.String... urlPatterns)` | Add a mapping for this filter to one or more URL patterns.
    `java.util.Collection<java.lang.String>` | `getServletNameMappings()` | Gets the currently available servlet name mappings of the Filter represented by this FilterRegistration.
    `java.util.Collection<java.lang.String>` | `getUrlPatternMappings()` | Gets the currently available URL pattern mappings of the Filter represented by this FilterRegistration.

    - ### Methods inherited from interface jakarta.servlet.Registration

      `getClassName, getInitParameter, getInitParameters, getName, setInitParameter, setInitParameters`

- - ### Method Detail

    - #### addMappingForServletNames

          void addMappingForServletNames​(java.util.EnumSet<DispatcherType> dispatcherTypes,
                                         boolean isMatchAfter,
                                         java.lang.String... servletNames)

      Add a mapping for this filter to one or more named Servlets.
      Parameters:
        `dispatcherTypes` - The dispatch types to which this filter should apply
        `isMatchAfter` - Should this filter be applied after any mappings defined in the deployment descriptor (`true`) or before?
        `servletNames` - Requests mapped to these servlets will be processed by this filter
      Throws:
        `java.lang.IllegalArgumentException` - if the list of servlet names is empty or null
        `java.lang.IllegalStateException` - if the associated ServletContext has already been initialised

    - #### getServletNameMappings

          java.util.Collection<java.lang.String> getServletNameMappings()

      Gets the currently available servlet name mappings of the Filter represented by this FilterRegistration.
      Returns:
        a Collection of the Servlet name mappings

    - #### addMappingForUrlPatterns

          void addMappingForUrlPatterns​(java.util.EnumSet<DispatcherType> dispatcherTypes,
                                        boolean isMatchAfter,
                                        java.lang.String... urlPatterns)

      Add a mapping for this filter to one or more URL patterns.
      Parameters:
        `dispatcherTypes` - The dispatch types to which this filter should apply
        `isMatchAfter` - Should this filter be applied after any mappings defined in the deployment descriptor (`true`) or before?
        `urlPatterns` - The URL patterns to which this filter should be applied
      Throws:
        `java.lang.IllegalArgumentException` - if the list of URL patterns is empty or null
        `java.lang.IllegalStateException` - if the associated ServletContext has already been initialised

    - #### getUrlPatternMappings

          java.util.Collection<java.lang.String> getUrlPatternMappings()

      Gets the currently available URL pattern mappings of the Filter represented by this FilterRegistration.
      Returns:
        a Collection of the URL pattern mappings