Solved

Ant

Posted on 2007-03-31
3
1,009 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 80
Setting strict transport security header in header not working 1 80
maven example error 3 52
reverse digits of a number using for loop 5 36
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

896 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now