Executing a batch file from a JSP page

Discussion in 'Java' started by vineetha, Oct 8, 2007.

  1. vineetha

    vineetha New Member

    Joined:
    Oct 8, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    I am trying to execute a batch file from a JSP page.But when i run the JSP page using tomcat,my tomcat stops the service.I am using Tomcat version 5.5 and JDK version 1.5.
    But when i run the same code using command prompt,i get the output.
    The following are the contents of my JSP page.

    HTML:
    <html>
    <title>hello world</html>
    <body bgcolor=pink>
    <%
    
    try
    { Process proc = Runtime.getRuntime().exec("C:/vin.bat"); 
    System.exit(0); 
    } 
    catch (Throwable t) 
    { 
    t.printStackTrace();
    } 
    
    %> 
    </body>
    </html>
    The batch file vin.bat contains the following lines:
    start c:/hello.txt

    Pls help me to figure out a solution.

    Thanks & Regards,
    Vineetha
     
    Last edited by a moderator: Oct 8, 2007

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice