You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Lmhelp1 <lm...@orange.fr> on 2014/06/14 23:56:45 UTC
Remote Tomcat webapps bidirectional communication
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?
Thank you and best regards.
--
Léa Massiot
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Remote Tomcat webapps bidirectional communication
Posted by Lmhelp1 <lm...@orange.fr>.
Hello André,
Thank you for your detailed answer, your accurate terminology and the
links you sent me.
About the scenario I described in my first message: I could make it work.
> [André Warnier wrote:]
> 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).
Ah? Ok.
"What" is actually taking care of the HTTP request then?
> [André Warnier wrote:]
> [...] for creating and sending a HTTP POST request [...]
> [...] 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 [...]
I actually have another scenario in which a C++ executable has to send a
HTTP request to a Tomcat Webapp.
I would need to build the HTTP request inside the C++ code and then send
it to the Tomcat Webapp.
I haven't yet looked for a solution...
Again thank you and best regards.
--
Léa
On 2014-06-16 5:51 PM, André Warnier wrote:
> 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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Remote Tomcat webapps bidirectional communication
Posted by André Warnier <aw...@ice-sa.com>.
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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Remote Tomcat webapps bidirectional communication
Posted by Aurélien Terrestris <at...@gmail.com>.
Hello
I think that application to application calls should be implemented
with web services (there is much choice but maybe heavy to implement).
When implementing such a solution, particularly if trafic goes through
internet, you must check that you're using a firewall in order to
avoid false requests that could from hackers.
A.T.
2014-06-14 23:56 GMT+02:00 Lmhelp1 <lm...@orange.fr>:
> 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?
>
> Thank you and best regards.
> --
> Léa Massiot
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org