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.

Web Modules<br />

84<br />

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

To build the hello1 application using the Ant utility, follow these steps:<br />

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

2. Type ant. This command will spawn any necessary compilations, copy files to the<br />

tut-install/javaeetutorial5/examples/web/hello1/build/ directory, create the WAR<br />

file, and copy it to the tut-install/javaeetutorial5/examples/web/hello1/dist/<br />

directory.<br />

Deploying aWAR File<br />

You can deploy a WAR file to the Application Server in a few ways:<br />

■ Copying the WAR into the domain-dir/autodeploy/ directory.<br />

■ Using the Admin Console.<br />

■ By running asadmin or ant to deploy the WAR.<br />

■ Using NetBeans IDE.<br />

All these methods are described briefly in this chapter; however, throughout the tutorial, you<br />

will use ant and NetBeans IDE for packaging and deploying.<br />

Setting the Context Root<br />

A context root identifies a web application in a <strong>Java</strong> <strong>EE</strong> server. You specify the context root when<br />

you deploy a web module. A context root must start with a forward slash (/) and end with a<br />

string.<br />

In a packaged web module for deployment on the Application Server, the context root is stored<br />

in sun-web.xml.<br />

To edit the context root, do the following:<br />

1. Expand your project tree in the Projects pane of NetBeans IDE.<br />

2. Expand the Web Pages and WEB-INF nodes of your project.<br />

3. Double-click sun-web.xml.<br />

4. In the editor pane, click Edit As XML.<br />

5. Edit the context root, which is enclosed by the context-root element.<br />

Deploying a PackagedWeb Module<br />

If you have deployed the hello1 application, before proceeding with this section, undeploy the<br />

application by following one of the procedures described in “Undeploying Web Modules” on<br />

page 88.<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!