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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

To use the Ant tool, execute the following command in the directory where you built and<br />

packaged the WAR:<br />

ant undeploy<br />

ConfiguringWeb Applications<br />

Web applications are configured by means of elements contained in the web application<br />

deployment descriptor.<br />

<strong>The</strong> following sections give a brief introduction to the web application features you will usually<br />

want to configure. A number of security parameters can be specified; these are covered in<br />

Chapter 30, “Securing Web Applications.”<br />

In the following sections, examples demonstrate procedures for configuring the Hello, World<br />

application. If Hello, World does not use a specific configuration feature, the section gives<br />

references to other examples that illustrate how to specify the deployment descriptor element.<br />

Mapping URLs toWeb Components<br />

When a request is received by the web container it must determine which web component<br />

should handle the request. It does so by mapping the URL path contained in the request to a<br />

web application and a web component. A URL path contains the context root and an alias:<br />

http://host:port/context-root/alias<br />

Setting the Component Alias<br />

<strong>The</strong> alias identifies the web component that should handle a request. <strong>The</strong> alias path must start<br />

with a forward slash (/) and end with a string or a wildcard expression with an extension (for<br />

example, *.jsp). Since web containers automatically map an alias that ends with *.jsp, you do<br />

not have to specify an alias for a JSP page unless you wish to refer to the page by a name other<br />

than its file name.<br />

<strong>The</strong> hello2 application has two servlets that need to be mapped in the web.xml file. You can<br />

edit a web application’s web.xml file in NetBeans IDE by doing 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 />

ConfiguringWeb Applications<br />

Chapter 3 • Getting Started withWeb Applications 89

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

Saved successfully!

Ooh no, something went wrong!