Creating a Servlet with the Wizard

You can create a servlet with the wizard that will guide you through the creation of the component. The wizard is invoked from a class diagram. It is only available if the language is Java.

You can either create a servlet without selecting any class, or select a class beforehand and start the wizard from the contextual menu of the class.

You can also create several servlets of the same type by selecting several classes at the same time. The wizard will automatically create one servlet per class. The classes you have selected in the class diagram become servlet classes. They are renamed to fit the naming conventions standard, and they are linked to the new servlet component.

The wizard for creation of a servlet lets you define the following parameters:

Wizard page

Description

Name

Name of the servlet component

Code

Code of the servlet component

Servlet type

You can select the following types: HttpServlet that supports the http protocol (most commonly used), GenericServlet that extends the servlet generic class, or user-defined that implies some customization as it does not implement anything

Servlet class

Class that provides the Servlet implementation.

Create symbol

Creates a component symbol in the diagram specified beside the Create symbol In check box. If a component diagram already exists, you can select one from the list. You can also display the diagram properties by selecting the Properties tool

Create Class Diagram for component classifiers

Creates a class diagram with a symbol for each class. If you have selected classes before starting the wizard, they are used to create the component. This option allows you to display these classes in a diagram

  1. Select Tools > Create Servlet from a class diagram.

    The Java Servlet Wizard dialog box is displayed.



    Note:

    If you have selected classes before starting the wizard, some of the following steps are omitted because the different names are created by default according to the names of the selected classes.

  2. Select a name and code for the servlet component and click Next.
  3. Select a servlet type and click Next.
  4. Select the servlet class name and click Next.
  5. At the end of the wizard, you have to define the creation of symbols and diagrams.

When you have finished using the wizard, the following actions are executed:

  • A servlet component is created

  • The servlet class is created and visible in the Browser. It is named after the original class if you have selected a class before starting the wizard

  • If you have not selected a class beforehand, it is prefixed after the original default component name to preserve coherence

  • Any diagrams associated with the component are created or updated