Howdy,

You want to be careful when running executables from your servlet (and
from a web server in general).  You're opening up security holes there.

>From your servlet, assuming the file is at "/home/myname/myprogram":

String execPath = "/home/myname/myprogram";
Runtime runtime = Runtime.getRuntime();
Process myProcess = runtime.exec(execPath);

// Wait for process to complete
p.waitFor();

Your executable needs to handle the case where it is concurrently
invoked by multiple servlets.  Alternatively, you could write a
singleton that coordinates access from your servlets to the executable.
The singleton would then do the above, and the servlets would just do
stuff like
ExecutableSingleton.getInstance().runProgram();

This is not really a tomcat question.  See the JavaDocs for the Runtime
and Process classes for more information.

Yoav Shapira
Millennium ChemInformatics


>-----Original Message-----
>From: Patrick Kosiol [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, December 03, 2002 10:26 AM
>To: Tomcat Users List
>Subject: Re: How to connect to a Data-File above the WEB-INF-Folder
from a
>servlet????
>
>Howdy ;-)
>
>thx 4 ur help, this it is what I wanted.
>
>But there is also another Question. I have a ".exe-file" that I want to
>start out of the servlet. Of course with some paramteters and one of my
>data-files as one of the parameters. Is that possible? And how do I do
>that?
>If that works and the .exe-file is accessing my data-file and another
>instance of the servlet does the same the tomcat can be crash or the
>servlet or so. How do I handle that?

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to