ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Massa, Ray" <>
Subject Calling Ant from a JSP Page (2)
Date Fri, 21 Sep 2001 00:15:52 GMT
First thanks for all the responses the first time! 

What I'm trying to do:

Call Ant from a JSP page. I created a JSP page that runs on Tomcat, with an
HTML text link that calls a Servlet with the following code:

try        {

PrintWriter out = res.getWriter();

out.write("step 1");            // debug

Process p = Runtime.getRuntime().exec("c:\\ant\\bin\\ant.bat -buildfile
c:\\ant\\bin\\build.xml -logfile c:\\ant\\bin\\foo.txt"); 

out.write("step 2");            // debug


out.print("<html><head><META HTTP-EQUIV='Refresh'

out.close(); <?xml:namespace prefix = o ns =
"urn:schemas-microsoft-com:office:office" />

} catch (IOException ex){

                        throw new ServletException("IOException: " +


The output of the page is "step 1setp 2". There are NO errors that I could
find-checked Java Console, Tomcat DOS window, all logs in
<tomcat_home>\logs. My guess is the output is causing problems. Can someone
suggest an easy want to encapsulate the output for ease of debugging?

The build.xml files calls Windows to execute a source safe batch
file. The batch file opens a project and gets (saves to local drive) all the
files from the project.

I can successfully run the string in the .exec(minus the extra '\''s) from
Run or an MS-DOS box.

Could someone suggest a cleaner way of doing this? 

Will there be an ANT API?


View raw message