Creating filter classes

The Filter wizard enables you to create Java™ filter classes for various Java EE filter types, such as authentication filters, encryption filters, and data compression filters.

Procedure

  1. Open the Filter wizard:
    1. Open the web perspective and display the Enterprise Explorer view.
    2. Right-click your web project and select New > Filter
    The Create Filter wizard opens.
  2. Specify a filter class:
    • To use an existing class, select the Use existing Filter class check box and then click Browse to locate the class.
    • To create a new filter class, specify the following information:
      1. The Source folder where the filter class is placed
      2. The Java package that the class belongs to (the class is added into a default package if you do not specify one)
        Note: Place the listener in the Java source folder.
      3. The Class name of the filter. The name that you type in the Name field is used to create a URL Mapping for the filter.
      4. The Superclass for the filter class. A filter that is created by this wizard can have any class that has Object in its hierarchy as its superclass. Click Browse to choose from the available superclasses.
  3. Click Next.
  4. Type a description for the filter. Optionally add initialization parameters or an alternative URL mapping, and then select Next.
  5. Select a modifier to specify whether your filter class is public, abstract, or final. (Classes cannot be both abstract and final.)
  6. The javax.servlet.Filter is provided as the default Interface. You do not have to implement the Filter interface if you subclass a class that implements Filter, or if you implement an interface that has Filter in its hierarchy.

    You can also add additional interfaces to implement. Click Add to open the Interface Selection dialog. In this dialog, as you type the name of the interface that you are interested in adding in the Choose interfaces field, the list of available interfaces that are listed in the Matching types list box updates dynamically to display only the interfaces that match the pattern. Select an interface to see the Qualifier and click Add. Click OK when you are finished. The qualifier that you chose appears in the Interfaces dialog.

  7. Choose which method stub you want to create.

    The Inherited abstract methods option adds stubs for inherited abstract methods, and that must be implemented (unless you intend to create an abstract class). Because the init(), destroy(), and doFilter() methods are all defined in the javax.servlet.Filter interface, stubs for these methods are automatically generated for each new filter class.

  8. Click Finish.

Results

The filter that you created appears under the Filters icon.
Icon that indicates the type of topic Task topic
Timestamp icon Last updated: July 17, 2017 21:58

File name: tcrtfilterclass.html