Creating a Filter

See Also

You create a filter by implementing the javax.servlet.Filter interface and providing a public constructor taking no arguments. The IDE provides a wizard to help you create two types of filters:

To create a Filter:

  1. Right-click the package where you want to put the filter and choose New > Other from the pop-up menu.
  2. Under Categories, select Web. Under File Types, select Filter. Click Next.
  3. Specify the fully qualified class name, the location and the servlet's package. Do not include a filename extension to the class name as this is added automatically when the file is created.
  4. Select the Wrap Request and Response Objects checkbox if you want the filter to wrap the request and response objects. For example, you can extend the capabilities of the request and response by allowing parameters to be set on the request before it is sent to the rest of the filter chain. Or you can keep track of the cookies that are set on the response. Note that some servers do not handle wrappers very well for forward or include requests.
  5. Click Finish to register the filter in the deployment descriptor. You can also register the filter afterwards, using the Servlet Filters section of the web.xml Visual Editor.
  6. Click Next to define initialization parameters or click Finish to accept the default configuration. The IDE opens the filter source code in the Source Editor.

For more information about filters, see the Java Servlet Technology Documentation available at

.

See Also
About Filters
Registering a Filter

Legal Notices