Forums Register Login

Executing programs

+Pie Number of slices to send: Send
Forgive my inexperience, but given an input from a client, can a servlet take that input and execute a program residing on the server-side? Just for an example, a webpage comes up with a button that says "Click to run Servletrunner" and the user clicks on it and the /usr/local/jsdk/bin/servletrunner daemon is started through the servlet somehow.
+Pie Number of slices to send: Send
I can't imagine why you would do that particular example, but yes, a servlet can essentially do anything a freestanding application can do. Most servlets books, including mine, have examples.
You have to use one of the java.lang.Runtime exec methods, get a process, and handle the input and output streams from the process. Kind of hard to debug from the servlet so I recommend you put the process in a helper object and test it stand-alone first.
Bill
------------------
author of:
There's a way to do it better - find it. -Edison. A better tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 515 times.
Similar Threads
How to reload a servlet class .. plz help
What Is SERVLETRUNNER?
applet-servlet communication
Connection reset by peer:JVM_recv in socket input stream read
error 403
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 11:41:11.