To add a new Servlet to a Nexaweb application project, follow these steps:
1. Select File > New > Other.
The Select a Wizard dialog appears.
2. Click + beside Web to expand it, select Servlet and click Next.
The Create Servlet wizard appears.
The Servlet wizard includes three dialogs:
|
Servlet Wizard Dialogs |
Description |
|
Servlet Class Settings |
Specifies servlet class information. For example, Class name, package, superclass, and so forth. |
|
Servlet Descriptor Settings |
Specifies the servlet's deployment descriptor information, including name, description, initialization parameters, and URL mappings. |
|
Servlet Java Settings |
Specifies the Servlet's Java settings including interfaces to implement, method stubs, modifiers, and so forth. |
3. Complete the class settings as follows:
|
Figure 26. New Servlet Class Settings |
Project: The project for this Servlet. Folder: The location of the source code for this Servlet, project\src directory by default. Java package: The package name of the Servlet class. Class Name: The name of the Servlet class. Superclass: Studio completes this field so that the new class will extend the proper Java EE HTTP Servlet super-class. For more information on this wizard, access the online help in Eclipse: Java Development User Guide, Getting Started, Basic Tutorial, Creating a Java Class. The settings in this dialog creates a new Java Servlet file with the name TestServlet.java in the folder JavaSource/. This file will be opened automatically. |
Click Next.
The descriptor settings dialog appears.
4. Complete the descriptor settings as follows:
|
Figure 27. New Servlet Descriptor Settings. |
Name: Name of the Servlet saved in the web.xml file. Description: Description of the Servlet in the web.xml file. Initialization Parameters: Allows you to specify initialization parameters for the Servlet. URL Mappings: The URL mapping relative to the application mapping used to access the Servlet. |
Click Next.
The Java settings dialog appears.
5. Complete the Java settings as follows:
|
Figure 28. New Servlet Java Settings. |
Modifiers: Specify the class modifiers to apply to the Servlet class. Interfaces: Specify any additional interfaces that this servlet implements in addition to the default, javax.servlet.Servlet. Method Stubs: Specifies which method stubs to create for the Servlet, including constructors from the superclass, inherited abstract methods, init, toString, getServletInfo, doGet, doPost, doPut, doDelete, doGet, destroy. |
6. Click Finish.
Studio adds the servlet to the project\src directory.