Well, to be honest, I still cannot figure out the design of your app. Which might be the cause for some misunderstandings.
As far as I've understood your requirements and question I recommend the following:
The IMHO easiest way to connect to a Webserver from within Java is by using the httpclient library of Apache (
http://hc.apache.org/httpclient-3.x/).
The servlet may access the ServletContext (e.g. to get initialization parameters) but _not_ the client. You can send further requests whenever you like to do so. What would you like to use the ServletContext for? You could use one servlet to start the process (and you should take whartungs suggestion to your heart) and another to stop the process. Or one servlet for both actions which takes different parameters to trigger the respective actions.
An ajax request could, as you suggested in your first post, check whether the status of the processt has already changed (do not forget to use proper synchronization otherwise you might run into visibility issues) and return an appropriate response to the client. Given whartungs suggestion above this servlet would call the getServiceStatus(pid) method. If the C-app has returned in the meantime, the ServerStatusResult should contain the required returncode of your C-app.
--
Wolfram Rittmeyer
[Message sent by forum member 'writtmeyer' (writtmeyer)]
http://forums.java.net/jive/thread.jspa?messageID=267370