Return-Path: Delivered-To: apmail-jakarta-ant-user-archive@jakarta.apache.org Received: (qmail 95374 invoked by uid 500); 21 Sep 2001 00:15:53 -0000 Mailing-List: contact ant-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: ant-user@jakarta.apache.org Delivered-To: mailing list ant-user@jakarta.apache.org Received: (qmail 95365 invoked from network); 21 Sep 2001 00:15:53 -0000 Message-ID: From: "Massa, Ray" To: ant-user@jakarta.apache.org Subject: Calling Ant from a JSP Page (2) Date: Thu, 20 Sep 2001 17:15:52 -0700 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C14232.93364550" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C14232.93364550 Content-Type: text/plain; charset="iso-8859-1" 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.flush(); out.print("
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=20 Tomcat, with an HTML text link that calls a Servlet with the following = code:

try        = {

PrintWriter out =3D=20 res.getWriter();

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

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

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

out.flush();

out.print("<html><head><META=20 HTTP-EQUIV=3D'Refresh'=20 CONTENT=3D'0;URL=3Dhttp://localhost:8080/foo.jsp?QProjName=3Dfoobar>&= lt;/head><body></body></html>");

out.close(); 

} catch (IOException = ex){

           =20            =20 throw new ServletException("IOException: " + ex.toString())

           =20 }

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

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

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

Could someone suggest a cleaner way of doing this? =

Will there be an ANT API?

Thanks!

------_=_NextPart_001_01C14232.93364550--