|
8.3. Creating Simple Web DeploymentWith a WAR file (or CAB file), it's time to turn to the deployment side of the Web development equation. If you're working on the same machine as a Web server, deployment can be as easy as copying a .war file to the application base directory for the server. Example 8-2 illustrates the point; this build file creates and copies a .war file over to the Tomcat webapps directory. When you (re)start Tomcat, the .war file will expand automatically into a directory of the same name (minus the .war extension), and the Web application will become available, in this case, at http://localhost:8080/app. (If you're deploying a servlet, the URL will reflect the servlet's package, as in http://localhost:8080/org/antbook/ch08/app for the servlet class org.antbook.ch08.app.) Example 8-2. Build file for Tomcat deployment (ch08/simple/build.xml)<?xml version="1.0" encoding = "UTF-8"?> <project default="main" basedir="."> <property name="src" location="source" /> <property name="wardir" location= "c:/tomcat/jakarta-tomcat-5.0.19/webapps"/> <property name="warfile" location="${wardir}/app.war"/> <target name="main" depends="war"> <echo message="Deploying the Web app...."/> </target> <target name="war" > <war destfile="${warfile}" webxml="${src}/app.xml" basedir="${bin}" /> </target> </project> You can use Ant's ftp task (see Chapter 4) for remote deployment to a Web server's base directories. |
|