This tip will show the way to start and stop Tomcat application by using ant build script.

Suppose name of your application name is newapp then in your build.xml include following.

<property name="name" value="newapp"/>
<taskdef name="start" classname="org.apache.catalina.ant.StartTask">
<classpath>
<path location="${appserver.home}/server/lib/catalina-ant.jar"/>
</classpath> 
</taskdef>
<taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
<classpath>
<path location="${appserver.home}/server/lib/catalina-ant.jar"/> 
</classpath>
</taskdef>
<target name="start" description="Start Tomcat application">
<start url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password }"
path="/${name}"/>
</target>

<target name="stop" description="Stop Tomcat application">
<stop url="${tomcat.manager.url}"
username="${ tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>

And make a file build.properties which contains variables used by build.xml

# Ant properties for building the springapp
appserver.home=${user.home}/jakarta-tomcat-5.0.28
deploy.path=${appserver.home}/webapps
tomcat.manager.url=http://localhost:8080/manager
tomcat.manager.username=admin 
tomcat.manager.password=tomcat