Lmhelp1 wrote:
Hello,

My question is about what code to write to allow two remote Tomcat webapps to communicate with one another through the Internet.

Let me explain more precisely what I would like to do.
(I'm just simplifying a bit the real situation).

- I have a Tomcat webapp running on a server in England.
- I have another Tomcat webapp running on a server in France.

- I have a JSP inside the England webapp.
- This JSP contains a form with two fields "First name" and "Last name".
- I would like to send these information to the France webapp.

- After the England form has been submitted, I can collect the information "First name" and "Last name" in a servlet.

Can you tell me what I shall do then to send these information to the France webapp?
Is it something like a "response.sendRedirect(..."?
How does it have to be written?

- Meantime, the France webapp needs to be able to wait for these information and, when they arrive, to get them and do something with them. For example store the "First name" and "Last name" in a database, etc.

What kind of a code has to be written in the France webapp?
Is it a servlet with a "doGet()" retrieving the information "First name" and "Last name"?

- Moreover, when the France webapp has finished it's job, it needs to tell the England webapp that it has finished, send it a file and some information.
So the communication has to be bidirectional.

Can you please give me some indications on how to start dealing with this? Or maybe a tutorial or an example?


This is only vaguely a Tomcat question, in the sense that :
- for receiving and processing a HTTP POST request (from a browser usually, but in your case it would be a Tomcat servlet or a program running somewhere else), a normal webapp is what you need. - for creating and sending a HTTP POST request, you will need a library that offers such functions, such as the HTTPClient library, found here : http://projects.apache.org/projects/httpcomponents_client.html

There is documentation and examples available at : 
http://hc.apache.org/index.html.
Make sure you read them.

Note that any java program could use this, there is nothing special about using it within a java servlet. And note that when one of your servlets issues a HTTP request to another server, Tomcat knows absolutely nothing about it, and there is no Tomcat code involved (on the request-sending side).

Note also that for what you describe as the "France webapp" above, that functionality does not necessarily need a Tomcat and a Tomcat webapp. You could use the code of
http://projects.apache.org/projects/httpcomponents_core.html
to create a stand-alone java network server, which just listens for this particular kind of request, and responds by the information that you describe. Similarly, your "England webapp" does not necessarily need to send the request to the France server as a HTTP request, nor expect a HTTP response.

What I believe would be the trickiest part in that kind of application, is to handle the various error scenarios : network down between England and France, French server down, French server taking a (too) long time to respond, French server returning an error, etc..


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to