File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes calling bat file from servlet running on tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "calling bat file from servlet running on tomcat" Watch "calling bat file from servlet running on tomcat" New topic
Author

calling bat file from servlet running on tomcat

Ravish Mittal
Greenhorn

Joined: Aug 17, 2011
Posts: 3
hi! guys.
i m new to coderanch...can anybody please tell me how to call a bat file from a servlet running on apache tomcat....
that apache is on window 2003 server...when i run the servlet in netbeans it runs fine but not in tomcat on window..
please help.
i forgot to tell that i m using runtime.getRuntime() method...
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3017
    
  35

Ravish Mittal wrote:...but not in tomcat on window..

What happened when you tried it? - any exception or something?


Founder of ExamLab and Systemup
See how I can help you to become an awesome programmer
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1075
    
    1

welcome to Javaranch Raavish !!!

Please post your code which you are trying to execute from Tomcat.

I think
Runtime.getRuntime().exec() method should work for you

~ abhay

Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I
Ravish Mittal
Greenhorn

Joined: Aug 17, 2011
Posts: 3
Devaka Cooray wrote:
Ravish Mittal wrote:...but not in tomcat on window..

What happened when you tried it? - any exception or something?

no exceptions....the bat file doesnt start...but the bat files of the system like paint and notepad etc. get called but they also dont get launched on frontend...they are only shown in the taskmanager...as SYSTEM process...
Ravish Mittal
Greenhorn

Joined: Aug 17, 2011
Posts: 3
Abhay Agarwal wrote:welcome to Javaranch Raavish !!!

Please post your code which you are trying to execute from Tomcat.

I think
Runtime.getRuntime().exec() method should work for you

~ abhay

thanks abhay..
try
{
String abc="rundll32 url.dll,FileProtocolHandler ";
Process p = Runtime.getRuntime().exec(abc + proname);
}
here proname is the process name which i pass from jsp page....
ex. C:/ravish.bat...or...C:\\ravish.bat..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calling bat file from servlet running on tomcat
 
Similar Threads
Not able to call a bat file from JAVA
classpath problem
How to Start Tomcat in Eclipse?
contents in the .bat file is not getting executed.
compiling ActionForm,ActionClass from command prompt,