aspose 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
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: 3102
    
  40

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

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


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1105
    
    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..
 
wood burning stoves
 
subject: calling bat file from servlet running on tomcat