title: create a war file
body: <p>I want to create a war file for project. The code works fine for creating jar file.
  when I run the following ant <code>build.xml</code> it still gives the message jar file BUILD SUCCESSFULL.</p>
  
  <pre><code>&lt;project name="struts-spring" basedir="../" default="all"&gt;
      &lt;!-- Project settings --&gt;
      &lt;property name="project.title" value="Sufalam Struts 2 Tutorials"/&gt;
      &lt;property name="project.jar.file" value="struts-spring.jar"/&gt;
  
        &lt;path id="class.path"&gt;
  
          &lt;fileset dir="lib"&gt;
  
            &lt;include name="**/*.jar"/&gt;
  
          &lt;/fileset&gt;
  
          &lt;fileset dir="libext"&gt;
  
            &lt;include name="**/*.jar"/&gt;
  
          &lt;/fileset&gt;
  
        &lt;/path&gt;
  
          &lt;!-- Classpath for Project --&gt;
  
          &lt;path id="compile.classpath"&gt;
  
              &lt;pathelement path ="lib/commons-beanutils.jar"/&gt;
  
              &lt;pathelement path ="lib/commons-digester.jar"/&gt;
  
              &lt;pathelement path ="lib/struts.jar"/&gt;
  
              &lt;pathelement path ="libext/servlet-api.jar"/&gt;
  
              &lt;pathelement path ="libext/catalina-ant.jar"/&gt;
  
              &lt;pathelement path ="classes"/&gt;
  
              &lt;pathelement path ="${classpath}"/&gt;
  
          &lt;/path&gt;
  
          &lt;!-- Check timestamp on files --&gt;
  
          &lt;target name="prepare"&gt;
  
              &lt;tstamp/&gt;
              &lt;copy
                  file="src/struts.xml"
                  todir="src/classes"/&gt;
  
  
          &lt;/target&gt;
          &lt;!-- Copy any resource or configuration files --&gt;
  
          &lt;target name="resources"&gt;
  
              &lt;copy todir="classes" includeEmptyDirs="no"&gt;
  
                  &lt;fileset dir="src/java"&gt;
  
                  &lt;patternset&gt;
  
                      &lt;include name="**/*.conf"/&gt;
  
                      &lt;include name="**/*.properties"/&gt;
  
                      &lt;include name="**/*.xml"/&gt;
  
                  &lt;/patternset&gt;
  
                  &lt;/fileset&gt;
  
              &lt;/copy&gt;
  
          &lt;/target&gt;
  
          &lt;!-- Normal build of application --&gt;
  
          &lt;target name="compile" depends="prepare,resources"&gt;
  
              &lt;javac srcdir="src" destdir="classes" 
                           debug="true" debuglevel="lines,vars,source"&gt;
  
                  &lt;classpath refid="class.path"/&gt;
  
              &lt;/javac&gt;
  
              &lt;jar
  
              jarfile="lib/${project.jar.file}"
  
              basedir="classes"/&gt;
  
          &lt;/target&gt;
          &lt;!-- Remove classes directory for clean build --&gt;
  
          &lt;target name="clean"
  
            description="Prepare for clean build"&gt;
  
            &lt;delete dir="classes"/&gt;
  
            &lt;mkdir  dir="classes"/&gt;
  
          &lt;/target&gt;
  
          &lt;!-- Build Javadoc documentation --&gt;
  
          &lt;target name="javadoc"
  
           description="Generate JavaDoc API docs"&gt;
  
              &lt;delete dir="./doc/api"/&gt;
  
              &lt;mkdir dir="./doc/api"/&gt;
  
              &lt;javadoc sourcepath="./src/java"
  
                  destdir="./doc/api"
  
                  classpath="${servlet.jar}:${jdbc20ext.jar}"
  
                  packagenames="*"
  
                  author="true"
  
                  private="true"
  
                  version="true"
  
                  windowtitle="${project.title} API Documentation"
  
                  doctitle="&amp;lt;h1&amp;gt;${project.title}
                            Documentation (Version ${project.version})&amp;lt;/h1&amp;gt;"
  
                  bottom="Copyright &amp;#169; 2002"&gt;
  
                  &lt;classpath refid="compile.classpath"/&gt;
  
              &lt;/javadoc&gt;
  
          &lt;/target&gt;
  
          &lt;!-- Build entire project --&gt;
  
          &lt;target name="project" depends="clean,prepare,compile"/&gt;
  
          &lt;!-- Create binary distribution --&gt;
  
          &lt;target name="dist"
  
              description="Create binary distribution"&gt;
  
            &lt;mkdir
  
              dir="${distpath.project}"/&gt;
  
  &lt;!--          &lt;jar
  
              jarfile="${distpath.project}/${project.distname}.jar"
  
              basedir="./classes"/&gt;
  
            &lt;copy
  
              file="${distpath.project}/${project.distname}.jar"
  
              todir="${distpath.project}"/&gt;--&gt;
  
  
  
            &lt;war
  
              basedir="../"
  
              warfile="${distpath.project}/${project.distname}.war"
  
              webxml="web.xml"&gt; &lt;/war&gt;
  
              &lt;copy file="${distpath.project}/${project.distname}.war"    todir="${distpath.project}"/&gt;
  
              &lt;!--&lt;exclude name="${distpath.project}/${project.distname}.war"/&gt;--&gt;
  
      &lt;/target&gt;
  
      &lt;!-- Build project and create distribution--&gt;
      &lt;target name="all" depends="project"/&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>please help me creating a war file.
  Thanks in advance.</p>