Package org.zkoss.web.servlet

## Class GenericFilter

- java.lang.Object
- - org.zkoss.web.servlet.GenericFilter

- All Implemented Interfaces:
    `javax.servlet.Filter`

      public abstract class GenericFilter
      extends java.lang.Object
      implements javax.servlet.Filter

  A generic class to help implementing servlet filter. Its role is like javax.servlet.GenericServlet to javax.servlet.Servlet.
  Author:
    tomyeh

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected javax.servlet.FilterConfig` | `_config` |

  - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `GenericFilter()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `destroy()` | Called by the web container to indicate to a filter that it is being taken out of service.
    `protected void` | `forward​(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.lang.String uri)` | Forward to the specified page.
    `protected void` | `forward​(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.lang.String uri, java.util.Map params, int mode)` | Forward to the specified page with parameters.
    `java.lang.String` | `getFilterName()` | Returns the filter's name.
    `java.lang.String` | `getInitParameter​(java.lang.String name)` | Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist.
    `java.util.Enumeration` | `getInitParameterNames()` | Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist.
    `javax.servlet.ServletContext` | `getServletContext()` | Returns the servlet context in which this filter is running.
    `protected void` | `include​(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.lang.String uri)` | Includes the specified page.
    `protected void` | `include​(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.lang.String uri, java.util.Map params, int mode)` | Includes the specified page with parameters.
    `protected void` | `init()` | A convenience method which can be overridden so that there's no need to call super.init(config).
    `void` | `init​(javax.servlet.FilterConfig config)` | Called by the web container to indicate to a filter that it is being placed into service.
    `protected void` | `sendRedirect​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String page, java.util.Map params, int mode)` | Redirects to another page.

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

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

    - ### Methods inherited from interface javax.servlet.Filter

      `doFilter`

- - ### Field Detail

    - #### _config

          protected javax.servlet.FilterConfig _config

  - ### Constructor Detail

    - #### GenericFilter

          protected GenericFilter()

  - ### Method Detail

    - #### init

          protected void init()
                       throws javax.servlet.ServletException

      A convenience method which can be overridden so that there's no need to call super.init(config).
      Throws:
        `javax.servlet.ServletException`
      See Also:
        `init(FilterConfig)`

    - #### init

          public final void init​(javax.servlet.FilterConfig config)
                          throws javax.servlet.ServletException

      Called by the web container to indicate to a filter that it is being placed into service. However, deriving class usually doesn't override this method but overriding `init()`.
      Specified by:
        `init` in interface `javax.servlet.Filter`
      Throws:
        `javax.servlet.ServletException`

    - #### getInitParameter

          public final java.lang.String getInitParameter​(java.lang.String name)

      Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist.

    - #### getInitParameterNames

          public final java.util.Enumeration getInitParameterNames()

      Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist.

    - #### getFilterName

          public final java.lang.String getFilterName()

      Returns the filter's name.

    - #### getServletContext

          public final javax.servlet.ServletContext getServletContext()

      Returns the servlet context in which this filter is running.

    - #### sendRedirect

          protected void sendRedirect​(javax.servlet.http.HttpServletRequest request,
                                      javax.servlet.http.HttpServletResponse response,
                                      java.lang.String page,
                                      java.util.Map params,
                                      int mode)
                               throws javax.servlet.ServletException,
                                      java.io.IOException

      Redirects to another page. Note: it supports only HTTP.

      It resolves "*" contained in URI, if any, to the proper Locale, and the browser code. Refer to `Servlets.locate(ServletContext, ServletRequest, String, Locator)` for details.

      Parameters:
        `page` - the page's uri; null to denote the same request
        `mode` - one of `Servlets.OVERWRITE_URI`, `Servlets.IGNORE_PARAM`, and `Servlets.APPEND_PARAM`. It defines how to handle if both uri and params contains the same parameter. mode is used only if both uri contains query string and params is not empty.
      Throws:
        `javax.servlet.ServletException`
        `java.io.IOException`

    - #### forward

          protected final void forward​(javax.servlet.ServletRequest request,
                                       javax.servlet.ServletResponse response,
                                       java.lang.String uri)
                                throws javax.servlet.ServletException,
                                       java.io.IOException

      Forward to the specified page.

      It resolves "*" contained in URI, if any, to the proper Locale, and the browser code. Refer to `Servlets.locate(ServletContext, ServletRequest, String, Locator)` for details.

      Throws:
        `javax.servlet.ServletException`
        `java.io.IOException`
      Since:
        3.6.3

    - #### forward

          protected final void forward​(javax.servlet.ServletRequest request,
                                       javax.servlet.ServletResponse response,
                                       java.lang.String uri,
                                       java.util.Map params,
                                       int mode)
                                throws javax.servlet.ServletException,
                                       java.io.IOException

      Forward to the specified page with parameters.

      It resolves "*" contained in URI, if any, to the proper Locale, and the browser code. Refer to `Servlets.locate(ServletContext, ServletRequest, String, Locator)` for details.

      Throws:
        `javax.servlet.ServletException`
        `java.io.IOException`
      Since:
        3.6.3

    - #### include

          protected final void include​(javax.servlet.ServletRequest request,
                                       javax.servlet.ServletResponse response,
                                       java.lang.String uri)
                                throws javax.servlet.ServletException,
                                       java.io.IOException

      Includes the specified page.

      It resolves "*" contained in URI, if any, to the proper Locale, and the browser code. Refer to `Servlets.locate(ServletContext, ServletRequest, String, Locator)` for details.

      Throws:
        `javax.servlet.ServletException`
        `java.io.IOException`
      Since:
        3.6.3

    - #### include

          protected final void include​(javax.servlet.ServletRequest request,
                                       javax.servlet.ServletResponse response,
                                       java.lang.String uri,
                                       java.util.Map params,
                                       int mode)
                                throws javax.servlet.ServletException,
                                       java.io.IOException

      Includes the specified page with parameters.

      It resolves "*" contained in URI, if any, to the proper Locale, and the browser code. Refer to `Servlets.locate(ServletContext, ServletRequest, String, Locator)` for details.

      Throws:
        `javax.servlet.ServletException`
        `java.io.IOException`
      Since:
        3.6.3

    - #### destroy

          public void destroy()

      Called by the web container to indicate to a filter that it is being taken out of service.

      This implementation does nothing.

      Specified by:
        `destroy` in interface `javax.servlet.Filter`