Creating HTTP servlets

This content applies to version 7.5.4, or later. You can model HTTP servlets by using a stereotyped UML class.
About this task

The stereotype <<HTTPServlet>> has associated stereotype properties that are used during the UML to Java™ transformation use. You can edit these properties with a customized user interface and contribute to the information in the web.xml file.

To create a HTTP servlet:

  1. Create or open a diagram in the target UML package where you want the servlet to be owned. The owning package determines the Java package of the generated siplet, and the namespace. Do not use the default package, which is the root package of the model.
  2. To create a new stereotyped class in the diagram, in the Palete, click HTTP Servlet, and rename the class.
  3. To see the HTTP Servlet specific properties, in the Properties view, click the HTTP tab. Edit the properties in the Properties view.

    Checking one or more of the method stubs adds that operation to the selected HTTP Servlet. When setting the Display Name, Servlet Name or when specifying a URL Mappings, you can use the keyword ${class_name} as a placeholder for the class name. For example, when the code is generated for the class above these values will be in the MyServlet. If the name of the class changes during refactoring or design, the current value of the class name is used during code generation.

  4. Click Filters > Show Signature to see the arguments of the methods, including the exceptions.

    The modeling toolkit extensions to the UML to Java Transformation generate the proper exceptions in the source code. You can set a preference to not use exceptions in the model.


Feedback