Adding Servlets to a Web Module

See Also

When you create a servlet using the New wizard and place it in a WEB-INF/classes subdirectory, 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, as shown in the following steps.

To add an existing servlet to a web module:

  1. From the IDE, copy or move the servlet into the web module's WEB-INF/classes directory. The Confirm Changes dialog box appears.
  2. In the Confirm Changes dialog, 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 and clicking Process.

If you do not process all the items in the Confirm Changes dialog, you will have to manually add the servlet and servlet-mapping entries to the deployment descriptor (web.xml).

tip  If you have a class that extends HttpServlet and the IDE does not recognize the class as a servlet, right-click the class and and choose Tools and choose Mark as Servlet from the contextual menu. When a class is recognized as a servlet, the class's property editor has properties for the URI, request parameters, and content language.
See Also
Editing Web Module Deployment Properties
Editing Servlet Properties

Legal Notices