| <?xml version="1.0" encoding="UTF-8"?> |
| <!DOCTYPE html |
| PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html> |
| <head> |
| <!-- /******************************************************************************* |
| * Copyright (c) 2000, 2005 IBM Corporation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * IBM Corporation - initial API and implementation |
| *******************************************************************************/ --> |
| <link rel="stylesheet" type="text/css" href="../../org.eclipse.wst.doc.user/common.css" /> |
| <title>Creating a new filter class</title> |
| </head> |
| <body id="twfltrwz"><a name="twfltrwz"><!-- --></a> |
| |
| <h1 class="topictitle1">Creating a new filter class</h1> |
| <div><div class="skipspace"> <p> The Filter wizard enables you to create Java filter |
| |
| classes for various J2EE filter types, such as authentication filters, encryption |
| |
| filters, and data compression filters.</p> |
| <p>To create a filter class, do |
| |
| the following: </p> |
| </div> |
| <ol><li class="skipspace"><span>Open the Filter wizard. To do this:</span><ol type="a"><li><span>Open the Web perspective and display the Project Explorer view.</span></li> |
| <li><span>Expand the project in which you want to create the filter</span></li> |
| <li><span>Expand the deployment descriptor icon</span></li> |
| <li><span>Right click on the <b>Filters</b> icon.</span></li> |
| <li><span>Select <span class="menucascade"><span class="uicontrol">New</span> > <span class="uicontrol">Filter</span></span> from the pop-up menu.</span></li> |
| </ol> |
| The <span class="uicontrol">Create Filter</span> wizard appears. </li> |
| <li class="skipspace"><span>Type a name and description for the filter. Notice that the name |
| |
| that you type in the <b>Name</b> field is used to create a URL Mapping for |
| |
| the filter. Optionally add initialization parameters or an alternative URL |
| |
| mapping, and then select <b>Next</b>.</span></li> |
| <li class="skipspace"><span>Specify the folder where the filter class will be placed. (You |
| |
| should place the filter in the Java source folder) Also specify the package |
| |
| that the class will belong to (it is added into a default package if you do |
| |
| not specify one), and the class name of the filter. </span></li> |
| <li class="skipspace"><span>Specify a superclass for the filter class. A filter created by |
| |
| this wizard can have any class that has Object in its hierarchy as its superclass. |
| |
| Click <span class="uicontrol">Browse</span> to choose from the available superclasses. |
| |
| When finished select <b>Next</b>.</span></li> |
| <li class="skipspace"><span>Select a modifier to specify whether your filter class is public, |
| |
| abstract, or final. (Classes cannot be both abstract and final.)</span></li> |
| <li class="skipspace"><span>The javax.servlet.Filter is provided as the default <span><span class="uicontrol">Interface</span></span>. |
| |
| You do not have to implement the Filter interface if you subclass a class |
| |
| that implements Filter, or if you implement an interface which has Filter |
| |
| in its hierarchy. </span> <p>You can also add additional interfaces to |
| |
| implement. Click <span><span class="uicontrol">Add</span></span> to open the <span><span class="uicontrol">Interface |
| |
| Selection</span></span> dialog. In this dialog, as you type the name of |
| |
| the interface that you are interested in adding in the <span><span class="uicontrol">Choose |
| |
| interfaces</span></span> field, the list of available interfaces listed |
| |
| in the <span><span class="uicontrol">Matching types</span></span> list box updates dynamically |
| |
| to display only the interfaces that match the pattern. Select an interface |
| |
| to see the <span><span class="uicontrol">Qualifier</span></span> and click <span><span class="uicontrol">Add</span></span>. |
| |
| Click <span><span class="uicontrol">OK</span></span> when you are finished. The qualifier |
| |
| that you chose appears in the Interfaces dialog.</p> |
| </li> |
| <li class="skipspace"><span>Choose which method stub you want to create.</span> <p>The <span><span class="uicontrol">Inherited |
| |
| abstract methods</span></span> 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.</p> |
| </li> |
| <li class="skipspace"><span>Click <span><span class="uicontrol">Finish</span></span>.</span></li> |
| </ol> |
| <div class="skipspace">The filter that you created appears under the Filters icon.</div> |
| </div> |
| <div><p><b class="relconceptshd">Related concepts</b><br /> |
| <a href="ccwebxml.html" title="">The Web deployment descriptor editor</a><br /> |
| </p> |
| </div> |
| </body> |
| </html> |