aspose file tools*
The moose likes Servlets and the fly likes Communicating with a process thru a browzer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Communicating with a process thru a browzer" Watch "Communicating with a process thru a browzer" New topic
Author

Communicating with a process thru a browzer

Ravi Adhav
Greenhorn

Joined: Jun 06, 2007
Posts: 5
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 ]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What sort of input? When you say "inputStream" do you need to pass a file to this process?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ravi Adhav
Greenhorn

Joined: Jun 06, 2007
Posts: 5
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.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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?
Ravi Adhav
Greenhorn

Joined: Jun 06, 2007
Posts: 5
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.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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.

-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ravi Adhav
Greenhorn

Joined: Jun 06, 2007
Posts: 5
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Communicating with a process thru a browzer