It should help if you add the batch file's path to your server's
PATH. Check the start-up scripts for your server.
[for example : startWebLogic.cmd]



-----Original Message-----
From: Sanjeev Verma [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 07, 2002 11:40 AM
To: [EMAIL PROTECTED]
Subject: Re: Can you use Runtime to execute something server side from a
s ervl et


you should be able to do this. A possibility why this is not happening is
because the bat file is in the same place as the .class file. Try placing
this file in a few places, like (just guessing):

 - The public folder (besides WEB-INF, alongside JSPs, HTMLs)
 - Besides web.xml

Please respond if you ARE able to use any of these, or an alternative.

Regards
Sanjeev

-----Original Message-----
From: Carter, Scott [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 07, 2002 8:37 PM
To: [EMAIL PROTECTED]
Subject: Can you use Runtime to execute something server side from a
servl et


I am trying to issue a command via java exec when a user hits my servlet.
The test batch file I am trying to execute is in the same directory as the
servlets .class file.  I have attached the code below.  This code works in a
normal java program (not a servlet).  Does this just have to do with the
directory I am running it in?

public class commandLineExec extends HttpServlet {


    public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException
    {

        // set Content and get Print Writer for the response
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();

        // execute a system command
        try {
                        Runtime r = Runtime.getRuntime();
                        Process p = r.exec("test.bat");

                }
                catch (java.io.IOException e)
                  {
                          System.out.println("in exception handler");
                  }

                        // write HTML to the response stream
                        out.println("<html>");
                        out.println("<head>");
                        out.println("<title>" + "Product Build Servlet" +
"</title>");
                        out.println("</head>");
                        out.println("<body bgcolor=\"white\">");
                        out.println("<h1>" + "The build has started!!!" +
"</h1>");
                        out.println("</body>");
                        out.println("</html>");
    }
}

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to