Solved

Ant

Posted on 2007-03-31
3
1,015 Views
Last Modified: 2013-12-29
This is part of build.xml written by someone else.

I am not able to see my servlet in web.xml

From the Ant script i see they are using jasper2 to automatically generate Web.xml

How do i add a servlet that i coded to web.xml


<jasper2
             validateXml="false"
             uriroot="${build.dir}/xmlapps"
             webXmlFragment="${build.dir}/webroot-generated_web.xml"
             outputDir="${build.dir}/xmlapps/WEB-INF/src" />

        <echo message="Compiling JSP Source"/>
 
    <javac destdir="${build.dir}/xmlapps/WEB-INF/classes"
           optimize="off"
           debug="on" failonerror="false"
           srcdir="${build.dir}/xmlapps/WEB-INF/src">  
           <classpath refid="class.path" />  
           <include name="**/*.java" />
    </javac>


     <loadfile property="webxmlappsinc.xml" srcFile="${build.dir}/webroot-generated_web.xml"/>

     <copy file="${build.dir}/xmlapps/WEB-INF/web-template.xml" toFile="${build.dir}/xmlapps/WEB-INF/web.xml"
        filtering="true" overwrite="true">
        <filterset begintoken="&lt;" endtoken="&gt;">
            <filter token="!-- JSP Servlet Insertion Point --" value="${webxmlappsinc.xml}"/>
        </filterset>
      </copy>

        <!-- Create XML Admin WAR File -->
        <jar jarfile="${build.dir}/xmlapps.war">
            <fileset dir="${build.dir}/xmlapps">
                <include name="**/**"/>
            </fileset>          
        </jar>        
  </target>

    <target name="clean">
      <delete dir="${build.dir}" />
    </target>
</project>
0
Comment
Question by:cutie_smily
3 Comments
 
LVL 30

Expert Comment

by:Mayank S
ID: 18831247
You might need to add it manually yourself. Or wait till somebody who knows Ant more than me posts.
0
 

Author Comment

by:cutie_smily
ID: 18832575
Above Ant code placing web.xml in a .ear file. And i place this .ear file in Jboss.
I tried to open .ear and save servlet in discriptor file but i am not able to save it.

none of them replying or helping out ..I am paying for this site every month to get some knowledge or help. It Was very useful but couple months i am not getting enough answers.Or i might be missing something. Anyway i will wait for the answers.

Thanks
0
 
LVL 8

Accepted Solution

by:
n_sachin1 earned 500 total points
ID: 18856011
The above ant structure pre-compiles the jsps in the web application and adds the generated java servlet references (from the jsps) into the web.xml. The web.xml that you see in the WEB-INF is a generated one

To add your servlet into the generated web.xml, you should add it to the template, that the generator is using.

In simpler words, add your servlet reference to ${build.dir}/xmlapps/WEB-INF/web-template.xml before the line:
<!-- JSP Servlet Insertion Point -->

Compare the ${build.dir}/xmlapps/WEB-INF/web-template.xml and the ${build.dir}/xmlapps/WEB-INF/web.xml and you'd understand what the ant script is doing.
Cheers
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question