Start of Content Area

Procedure documentation Initializing Filters  Locate the document in its SAP Library structure

Use

You initialize your filter using its init() method. It is passed a FilterConfig object as a parameter. With the FilterConfig object, your filter can obtain initialization parameters that you have defined for it in the deployment descriptor (within the <filter> block of tags) or can get access to parameters that are stored in the ServletContext object for the current application.

Procedure

To retrieve initialization parameters that you have specified in the deployment descriptor, you can use getInitParameter() method of the FilterConfig object.

Example

If you have declared the following initialization parameters for your filter:

<filter>

……

<init-param>

   <param-name> parameter1 </param-name>

   <param-value> value1 </param-value>

</init-param>

</filter>

The following code extract retrieves the parameter value and stores it in a variable for future use by the filter:

public void init(FilterConfig config) throws ServletException {

      String param = config.getInitParameter("parameter1");

}

 

For more information on the methods of the FilterConfig object, refer to the Servlet 2.3 API documentation.

 

End of Content Area