Adding an Existing Servlet to a Web Module

See Also

When you create a servlet using the File and choose New wizard and place it in a web module, the IDE handles certain tasks for you. These tasks include automatically updating the web module's deployment descriptor to include the servlet and setting certain properties for the servlet. This practice is recommended for developing servlets in the IDE.

If you have an existing servlet class file that you want to add to a web module, a different procedure is required.

To add an existing servlet to a web module:

  1. In the Filesystems tab of the Explorer, right-click the relevant servlet's .class file, and choose Copy.
  2. Select the destination web module's WEB-INF/classes/ directory. Choose Paste. The Confirm Changes dialog box appears.
  3. In the Confirm Changes dialog box, click Process All to register the new servlet in the web module's deployment descriptor. Alternatively, you can work with a single item by selecting it, then clicking Process.

If you do not click Process All in the Confirm Changes dialog, you will have to register the new servlet in the destination web module's deployment descriptor by hand, using the following steps:

To register an added servlet in the web module's deployment descriptor:

Tip Note that this feature might not be included in your version of the IDE. If it is not available, you can edit the deployment descriptor (web.xml) file using the editor of your choice.
  1. Right-click the web.xml node, and choose Properties.
  2. In the Deployment panel of the web.xml properties window, click the ellipses (...) in the Servlets value field to display the Servlets property editor.
  3. In Servlets property editor, click Add to display the Add Servlet dialog box.
  4. In the Add Servlet dialog box, type, or browse for, the servlet class name, and type in the name by which you want to identify the servlet.
  5. Click OK to close the Add Servlet dialog box, then click OK to close the Servlets property editor.
Tip If you want to execute servlets that are Java sources, you need to mark them as servlets using Tools and choose Mark as Servlet, configure them in the Servlets property editor, and set the proper URI for execution.
See Also
Editing Web Module Deployment Properties
Editing Servlet Properties

Legal Notices