views:

22

answers:

1

I have jsp, which does ajax requests to a controller and passes IP's and shell commands that server will do. For example, ajax request has params "127.0.0.1", "ls -la, ls". (commands - is a list) Server executes these commands in separate threads(one thread per IP, or other) and updates table on jsp which contains output data of these commands. So how it can be implemented? How can I get results from each thread and ajax update table ?

Thanks!

A: 

Your question reads a little like you're using "jsp" to refer to your client code - JSP is a server-side scripting language.

That said, and assuming that your JSP (on the server) is using System.exec( ... ) to run the shell commands, that call will actually return a Process object. You'll need to wait for the process to complete, with the waitfor() method, then you can get the output stream off the process and read in the input, parse it, and then echo it out in your JSP.

Curtis
you provided a java 1.4.x api link (unfortunately google always returns 1.4.x first), I changed it to a current (1.6) version. Also, I edited your formatting to make it more SO-like
seanizer