Writing Ant Targets to Deploy to Tomcat Web Server 4
See Also
When you install the IDE, the installer automatically registers the bundled Tomcat
Web Server with the IDE. You can also configure the IDE to deploy web applications to other
installations of supported versions of the Tomcat Web Server. These versions need to be
registered first. Unsupported versions of the Tomcat
Web Server cannot be registered with the IDE. Instead, for these versions you can create
Ant targets for starting and stopping the Tomcat Web Server
and for the deployment of web applications, JSP pages, and servlets.
To write Ant targets to deploy to Tomcat Web Server 4:
- Create a web application project.
- In the Files window (Ctrl-2), expand the project node, expand the
nbproject node, and double-click the project.properties node. Change the
build.web.dir property as follows:
c:/Program Files/Apache Group/Tomcat 4.1/webapps/MyWebAppProjectName
Make sure that the path above points to the Tomcat Web server's webapps folder,
and replace MyWebAppProjectName with the name of your web application project.
- Double-click the build.xml file
and add the following targets right above the closing </project> tag:
- A target to start the server:
<target name="startcat4" depends="init">
<exec executable="c:\Program Files\Apache Group\Tomcat 4.1\bin\startup.bat">
<env key="CATALINA_HOME" value="c:\Program Files\Apache Group\Tomcat 4.1"/>
<env key="CATALINA_BASE" value="c:\Program Files\Apache Group\Tomcat 4.1"/>
</exec>
</target>
- A target to deploy the application:
<target name="run" depends="compile">
<exec executable="C:\Program Files\mozilla.org\Mozilla\mozilla.exe">
<arg value="http://localhost:8080/MyWebAppProjectName/${client.urlPart}"/>
</exec>
</target>
- A target to stop the server:
<target name="stopcat4" depends="init">
<exec executable="c:\Program Files\Apache Group\Tomcat 4.1\bin\shutdown.bat">
<env key="CATALINA_HOME" value="c:\Program Files\Apache Group\Tomcat 4.1"/>
<env key="CATALINA_BASE" value="c:\Program Files\Apache Group\Tomcat 4.1"/>
</exec>
</target>
In the targets above, make sure that all the values are correct
for your environment and Tomcat Web Server installation. In the Run target,
replace MyWebAppProjectName with the name of your web application project.
To integrate the Ant targets with the IDE:
- In the Files window, expand the build.xml node, find the startcat4
target node, right-click it, and choose Create Shortcut. You can add a menu
item, toolbar button, or keyboard shortcut for each of your new targets.
- Right-click the project node, choose Properties, and click Run.
Use the Relative URL field to define the client.urlPart, which you
specified in the Run target above. For example, type index.jsp (without
a slash, because the slash is defined in the Run target).
- In the projects window, right-click the project node and choose Build Project.
Check that the project is built to the folder that you specified in step 1 above.
To deploy the web application:
- Click the shortcut you defined to start the Tomcat Web Server.
- Click the shortcut you defined to deploy the web application, JSP page, or servlet.
The JSP page or servlet specified by the client.urlPart property is
displayed in the browser that you defined in the Run target.
- See Also
- About the Tomcat Web Server
- Viewing the Tomcat Web Server in the IDE
- Customizing the Tomcat Web Server
- Customizing the Tomcat Configuration File
Legal Notices