File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling bat file from servlet running on tomcat

 
Ravish Mittal
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 4116
195
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravish Mittal wrote:...but not in tomcat on window..

What happened when you tried it? - any exception or something?
 
Abhay Agarwal
Ranch Hand
Posts: 1375
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ravish Mittal
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic