Package javax.servlet
Class GenericFilter
- java.lang.Object
- 
- javax.servlet.GenericFilter
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- Filter,- FilterConfig
 - Direct Known Subclasses:
- HttpFilter
 
 public abstract class GenericFilter extends java.lang.Object implements Filter, FilterConfig, java.io.Serializable Provides a base class that implements the Filter and FilterConfig interfaces to reduce boilerplate when writing new filters.- Since:
- Servlet 4.0
- See Also:
- Filter,- FilterConfig, Serialized Form
 
- 
- 
Constructor SummaryConstructors Constructor Description GenericFilter()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description FilterConfiggetFilterConfig()Obtain the FilterConfig used to initialise this Filter instance.java.lang.StringgetFilterName()Get the name of the filter.java.lang.StringgetInitParameter(java.lang.String name)Returns aStringcontaining the value of the named initialization parameter, ornullif the parameter does not exist.java.util.Enumeration<java.lang.String>getInitParameterNames()Returns the names of the filter's initialization parameters as anEnumerationofStringobjects, or an emptyEnumerationif the filter has no initialization parameters.ServletContextgetServletContext()Returns a reference to theServletContextin which the caller is executing.voidinit()Convenience method for sub-classes to save them having to callsuper.init(config).voidinit(FilterConfig filterConfig)Called by the web container to indicate to a filter that it is being placed into service.
 
- 
- 
- 
Method Detail- 
getInitParameterpublic java.lang.String getInitParameter(java.lang.String name) Description copied from interface:FilterConfigReturns aStringcontaining the value of the named initialization parameter, ornullif the parameter does not exist.- Specified by:
- getInitParameterin interface- FilterConfig
- Parameters:
- name-- Stringspecifying the name of the initialization parameter
- Returns:
- Stringcontaining the value of the initialization parameter
 
 - 
getInitParameterNamespublic java.util.Enumeration<java.lang.String> getInitParameterNames() Description copied from interface:FilterConfigReturns the names of the filter's initialization parameters as anEnumerationofStringobjects, or an emptyEnumerationif the filter has no initialization parameters.- Specified by:
- getInitParameterNamesin interface- FilterConfig
- Returns:
- Enumerationof- Stringobjects containing the names of the filter's initialization parameters
 
 - 
getFilterConfigpublic FilterConfig getFilterConfig() Obtain the FilterConfig used to initialise this Filter instance.- Returns:
- The config previously passed to the init(FilterConfig)method
 
 - 
getServletContextpublic ServletContext getServletContext() Description copied from interface:FilterConfigReturns a reference to theServletContextin which the caller is executing.- Specified by:
- getServletContextin interface- FilterConfig
- Returns:
- ServletContextobject, used by the caller to interact with its servlet container
- See Also:
- ServletContext
 
 - 
initpublic void init(FilterConfig filterConfig) throws ServletException Description copied from interface:FilterCalled by the web container to indicate to a filter that it is being placed into service. The servlet container calls the init method exactly once after instantiating the filter. The init method must complete successfully before the filter is asked to do any filtering work.The web container cannot place the filter into service if the init method either: - Throws a ServletException
- Does not return within a time period defined by the web container
 - Specified by:
- initin interface- Filter
- Parameters:
- filterConfig- The configuration information associated with the filter instance being initialised
- Throws:
- ServletException- if the initialisation fails
 
 - 
initpublic void init() throws ServletExceptionConvenience method for sub-classes to save them having to callsuper.init(config). This is a NO-OP by default.- Throws:
- ServletException- If an exception occurs that interrupts the Filter's normal operation
 
 - 
getFilterNamepublic java.lang.String getFilterName() Description copied from interface:FilterConfigGet the name of the filter.- Specified by:
- getFilterNamein interface- FilterConfig
- Returns:
- The filter-name of this filter as defined in the deployment descriptor.
 
 
- 
 
-