Creating servlets

The servlet wizard helps you create Java™ servlets by walking you through the creation process and by providing you with output files that you can use or that you can modify for use with your Web application. The servlets can run on J2EE-compliant Web servers.

To create a servlet using the Servlet wizard, complete the following steps:

  1. From the J2EE perspective, expand your dynamic project in the Project Explorer view.
  2. Right click on the Servlet icon, and select New > Servlet from the pop-up menu. The Create Servlet wizard appears.
  3. In the Create a Servlet page, supply the following:
    1. Type the name and description of the servlet. Notice that the name that you type in the name field is used as the default URL mapping.
    2. Optionally add or remove initialization parameters and URL mappings.
    3. Either click Finish or select Next for more options.
  4. Select a modifier to specify whether your servlet class is public, abstract, or final. (Classes cannot be both abstract and final.)
    1. The javax.servlet.Servlet is provided as the default Interface. 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 listed in the Matching types list box updates dynamically to display only the interfaces that match the pattern. Choose an interface to see the Qualifier, and then click Add. Click OK when you are finished.

    2. Select any appropriate method stubs to be created in the servlet file. The stubs created by using the Inherited abstract methods option must be implemented if you do not intend to create an abstract servlet. This is not true for Constructors from superclass.
    3. Click Finish. The servlet is generated.

Related concepts
Servlets