10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ConfiguringWeb Applications<br />

90<br />

5. Click Open Project.<br />

6. Expand the project tree in the Projects pane.<br />

7. Expand the Web pages node and then the WEB-INF node in the project tree.<br />

8. Double-click the web.xml file inside the WEB-INF node.<br />

<strong>The</strong> following steps describe how to make the necessary edits to the web.xml file, including how<br />

to set the display name and how to map the servlet components. Because the edits are already in<br />

the file, you can just use the steps to view the settings.<br />

To set the display name:<br />

1. Click General at the top of the editor to open the general view.<br />

2. Enter hello2 in the Display Name field.<br />

To perform the servlet mappings:<br />

1. Click Servlets at the top of the editor to open the servlets view.<br />

2. Click Add Servlet.<br />

3. In the Add Servlet dialog, enter GreetingServlet in the Servlet Name field.<br />

4. Enter servlets.GreetingServlet in the Servlet Class field.<br />

5. Enter /greeting in the URL Pattern field.<br />

6. Click OK.<br />

7. Repeat the preceding steps, except enter ResponseServlet as the servlet name,<br />

servlets.ResponseServlet as the servlet class, and /response as the URL pattern.<br />

If you are not using NetBeans IDE, you can add these settings using a text editor.<br />

To package the example with NetBeans IDE, do the following:<br />

1. Select File→Open Project.<br />

2. In the Open Project dialog, navigate to:<br />

tut-install/javaeetutorial5/examples/web/<br />

3. Select the hello2 folder.<br />

4. Select the Open as Main Project check box.<br />

5. Click Open Project.<br />

6. In the Projects tab, right-click the hello2 project and select Build.<br />

To package the example with the Ant utility, do the following:<br />

1. In a terminal window, go to tut-install/javaeetutorial5/examples/web/hello2/.<br />

2. Type ant. This target will build the WAR file and copy it to the<br />

tut-install/javaeetutorial5/examples/web/hello2/dist/ directory.<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!