background image

Deploying a WAR File

<< Packaging Web Modules | Deploying with the Admin Console >>
<< Packaging Web Modules | Deploying with the Admin Console >>

Deploying a WAR File

5. Click Open Project Folder.
6. In the Projects tab, right-click the hello1 project and select Build Project.
To build the hello1 application using the Ant utility, follow these steps:
1. In a terminal window, go to tut-install/javaeetutorial5/examples/web/hello1/.
2. Type ant. This command will spawn any necessary compilations, copy files to the
tut-install/javaeetutorial5/examples/web/hello1/build/ directory, create the WAR
file, and copy it to the tut-install/javaeetutorial5/examples/web/hello1/dist/
directory.
Deploying a WAR File
You can deploy a WAR file to the Application Server in a few ways:
Copying the WAR into the domain-dir/autodeploy/ directory.
Using the Admin Console.
By running asadmin or ant to deploy the WAR.
Using NetBeans IDE.
All these methods are described briefly in this chapter; however, throughout the tutorial, you
will use ant and NetBeans IDE for packaging and deploying.
Setting the Context Root
A context root identifies a web application in a Java EE server. You specify the context root when
you deploy a web module. A context root must start with a forward slash (/) and end with a
string.
In a packaged web module for deployment on the Application Server, the context root is stored
in sun-web.xml.
To edit the context root, do the following:
1. Expand your project tree in the Projects pane of NetBeans IDE.
2. Expand the Web Pages and WEB-INF nodes of your project.
3. Double-click sun-web.xml.
4. In the editor pane, click Edit As XML.
5. Edit the context root, which is enclosed by the context-root element.
Deploying a Packaged Web Module
If you have deployed the hello1 application, before proceeding with this section, undeploy the
application by following one of the procedures described in
"Undeploying Web Modules" on
page 88
.
Web Modules
The Java EE 5 Tutorial · September 2007
84