Solved

Ant

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

746 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

16 Experts available now in Live!

Get 1:1 Help Now