Chapter 14 Working with Java


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 dropdown listbox. 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

Steps To create a servlet with the wizard:

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

    The Java Servlet Wizard dialog box appears.
  2. Select a name and code for the servlet component and click Next.

    Note   Steps of the wizard
    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.

  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:

 


Copyright (C) 2005. Sybase Inc. All rights reserved.