background image

Perform the Servlet Mappings

<< Configuring Web Applications | Declaring WelcomeFiles >>
<< Configuring Web Applications | Declaring WelcomeFiles >>

Perform the Servlet Mappings

4. Select the Open as Main Project check box.
5. Click Open Project Folder.
6. Expand the project tree in the Projects pane.
7. Expand the Web pages node and then the WEB-INF node in the project tree.
8. Double-click the web.xml file inside the WEB-INF node.
The following steps describe how to make the necessary edits to the web.xml file, including how
to set the display name and how to map the servlet components. Because the edits are already in
the file, you can just use the steps to view the settings.
To set the display name:
1. Click General at the top of the editor to open the general view.
2. Enter hello2 in the Display Name field.
To perform the servlet mappings:
1. Click Servlets at the top of the editor to open the servlets view.
2. Click Add Servlet.
3. In the Add Servlet dialog, enter GreetingServlet in the Servlet Name field.
4. Enter servlets.GreetingServlet in the Servlet Class field.
5. Enter /greeting in the URL Pattern field.
6. Click OK.
7. Repeat the preceding steps, except enter ResponseServlet as the servlet name,
servlets.ResponseServlet
as the servlet class, and /response as the URL pattern.
If you are not using NetBeans IDE, you can add these settings using a text editor.
To package the example with NetBeans IDE, do the following:
1. Select File
Open Project.
2. In the Open Project dialog, navigate to:
tut-install/javaeetutorial5/examples/web/
3. Select the hello2 folder.
4. Select the Open as Main Project check box.
5. Click Open Project Folder.
6. In the Projects tab, right-click the hello2 project and select Build Project.
Configuring Web Applications
The Java EE 5 Tutorial · September 2007
90