This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
Hi, I am looking for a way to pass (through a browzer) an input to a process which is waiting to recieve an input. In my servlet, I already have a reference to this waiting process to which I want to pass the input stream. How can I achieve this? [ June 23, 2008: Message edited by: Ravi Adhav ]
Hi I just want to pass a reply to a commandline process :that is in a form of a string. The command line process is waiting , expecting a string. I dont see any methods in the Process class which would help me in this.
You could implement this yourself by writing your own ServerSocket program and passing the input that way. However, since you posted this in the Servlet forum, and since you mention a browser, then perhaps you are looking for an HTTP based way of doing this?
If so, you need to create an HTML form that gathers the user input and (using POST or GET) sends a request to a Servlet which can then extract the input and forward it to your server-side process. Does this make sense?
Joined: Jun 06, 2007
I already have the input string collected in the servlet. Also in my servlet I have a reference to that process which is waiting for the input. The issue I am facing is how do I forward this string (which I have in the servlet) from the servlet to the waiting process. That is I want to pass the string from the servlet to the process, so that it can resume its execution.... Appreciate if you could please hepl me with this.
I guess you'd have to explain, a little more, what you mean by 'process'.
Did you start another process on the machine with System.exec? Do you mean another Java thread? Can you describe this other process, how it was started, and how you were able to obtain a handle to it in your servlet?
I'm thinking this is no longer servlet specific. Where it should go depends on your answers to the questions above.
I am looking for running any console-program controlled by the browzer in future. However for now I was running a simple interactive java program (console based only) and was seeing if I could control it from the browzer. The java program I'd started using Runtime.exec() method, so could save the reference of this process in the session object. So when this program halts for the next input, I want to pass the string to this program from a servlet. So in short I want to pass a string from my servlet to a java program which is awaiting the string as input.