You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Léa Massiot <lm...@orange.fr> on 2012/08/29 13:30:33 UTC
Re: Pass an object from one Webapp to another on two differents
servers
I posted mistakenly in the "Tomcat" forum instead of here "Tomcat-User" (I
just moved my thread).
Can you help me?
Best regards.
--
View this message in context: http://tomcat.10.n6.nabble.com/Pass-an-object-from-one-Webapp-to-another-on-two-differents-servers-tp4985870p4985967.html
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Pass an object from one Webapp to another on two differents
servers
Posted by Léa Massiot <lm...@orange.fr>.
Hello Casper.
Yes, we are ok now.
I think the responses to your question are in my previous posts :)
Thank you for helping me out.
--
View this message in context: http://tomcat.10.n6.nabble.com/Pass-an-object-from-one-Webapp-to-another-on-two-differents-servers-tp4985870p4986207.html
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Pass an object from one Webapp to another on two differents servers
Posted by Casper Wandahl Schmidt <ka...@gmail.com>.
See inline, marked with ---- since Outlook does not like auto-indent when
replying
Med venlig hilsen/Kind regards
Casper/Kalle
-----Original Message-----
From: Léa Massiot [mailto:lmhelp1@orange.fr]
Sent: 3. september 2012 09:47
To: users@tomcat.apache.org
Subject: Re: Pass an object from one Webapp to another on two differents
servers
According to the notations in my first post, the successive URLs are:
1) SERVER_1/WEBAPP_1/HTML_1
2) SERVER_2/WEBAPP_2/SERVLET_2
3) SERVER_1/WEBAPP_1/JSP_1
"SERVLET_2" does all the work it has to do using the information provided by
the user in the "HTML_1"'s form "F1".
When the work is over, "SERVLET_2" redirects towards "JSP_1"
It's a classical client <-> server scheme...
--------------
Cws: I thought that SERVLET_2 opened a connection to JSP_1 and retrieved the
output and then send that to the client as output for the client request til
SERVLET_2. That's why I thought that the client would still be on SERVER_2.
As it is now it makes perfect sense, now I just don't get why you needed to
transfer anything? Does SERVLET_2 contact JSP_1? What happens if that is the
case (you said you needed to transfer some information to SERVER_1, how is
that done)?
Maybe I'm jost lost on what you really needed and trying to solve a
bigger/harder problem than what you needed. If you current solution works
all should be fine and we should stop the discussion :)
--------------
But maybe I'm not getting properly your questions?
Best regards.
--
View this message in context:
http://tomcat.10.n6.nabble.com/Pass-an-object-from-one-Webapp-to-another-on-
two-differents-servers-tp4985870p4986202.html
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
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
Re: Pass an object from one Webapp to another on two differents
servers
Posted by Léa Massiot <lm...@orange.fr>.
According to the notations in my first post, the successive URLs are:
1) SERVER_1/WEBAPP_1/HTML_1
2) SERVER_2/WEBAPP_2/SERVLET_2
3) SERVER_1/WEBAPP_1/JSP_1
"SERVLET_2" does all the work it has to do
using the information provided by the user in the "HTML_1"'s form "F1".
When the work is over, "SERVLET_2" redirects towards "JSP_1"
It's a classical client <-> server scheme...
But maybe I'm not getting properly your questions?
Best regards.
--
View this message in context: http://tomcat.10.n6.nabble.com/Pass-an-object-from-one-Webapp-to-another-on-two-differents-servers-tp4985870p4986202.html
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Pass an object from one Webapp to another on two differents servers
Posted by Casper Wandahl Schmidt <ka...@gmail.com>.
See comments inline
Med venlig hilsen/Kind regards
Casper W. Schmidt
Den 31-08-2012 13:18, Léa Massiot skrev:
> The user doesn't shift from "WEBAPP_1" to "WEBAPP_2" for good.
> The user will go on with "WEBAPP_1" after "WEBAPP_2" has done what it has to
> do after the form ("F1") submission.
That depends. As you told it Servlet_2 (on server2/app2) contacts
server1/app1 to get the response and show it to the client. So does the
response contain links to pages that redirect the user to server1/app1
again? After what you have told us I would say the address bar of the
client/browser would be: server1.com/webapp1/f1.jsp (or whatever
extension), then when that form is submitted it changes to
server2.com/webapp2/Servlet_2 (which shows the response from
server1.com/webapp1/j1.jsp). Then when the user clicks any link he/she
will be directed back to server1.com/webapp1/anything-new because that
is the path that j1.jsp in webapp1 would return as part of the response?
But what if j1.jsp simply returns a relative URL (like front.jsp), then
clicking that link (with the before mentioned address in the bar) would
make the client request server2.com/webapp2/front.jsp instead of
server1.com/webapp1/front.jsp or am I wrong?
My advice is to turn it around and keep everything the user sees on
server1 and then let Servlet_1 handle the POST to Servlet_2 on server2
and act upon the response from Servlet_2 :)
>
> Best regards.
>
>
>
> --
> View this message in context: http://tomcat.10.n6.nabble.com/Pass-an-object-from-one-Webapp-to-another-on-two-differents-servers-tp4985870p4986105.html
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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
Re: Pass an object from one Webapp to another on two differents
servers
Posted by Léa Massiot <lm...@orange.fr>.
The user doesn't shift from "WEBAPP_1" to "WEBAPP_2" for good.
The user will go on with "WEBAPP_1" after "WEBAPP_2" has done what it has to
do after the form ("F1") submission.
Best regards.
--
View this message in context: http://tomcat.10.n6.nabble.com/Pass-an-object-from-one-Webapp-to-another-on-two-differents-servers-tp4985870p4986105.html
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Pass an object from one Webapp to another on two differents servers
Posted by Casper Wandahl Schmidt <ka...@gmail.com>.
Med venlig hilsen/Kind regards
Casper W. Schmidt
Den 31-08-2012 11:42, Léa Massiot skrev:
> (Warning: there is some "raw text" in this post.)
>
> Hello Casper. Hello list.
> Thank you for your answer and your advices.
>
> Here is some interesting litterature related to my problem:
> "Redirecting from a servlet to an exterior URL using a POST"
>
> http://www.mail-archive.com/servlet-interest@java.sun.com/msg49110.html
Well as they say in that thread POST is not any more secure than showing
the parameters in the querystring (using GET) so no real reason for
using POST for that :)
>
> Which led me to write a programmatic POST using this code:
> "How to use HttpURLConnection POST data to web server?"
>
> http://www.xyzws.com/Javafaq/how-to-use-httpurlconnection-post-data-to-web-server/139
>
> And, in "SERVLET_2", I replaced the code (see my first post in this thread)
> with this one:
You could also do it the other way around. Make F1 from Server1 POST to
J1.jsp (still on Server1), which then makes a similar POST request (with
the parameters necessary from F1) to Servlet_2, reads the result ("ok")
from the response coming from Servlet_2 and then display the right thing
in J1.jsp. That would be cleaner than letting the user shift from
Server1/app1 to Server2/app2 for good (where is the user supposed to
continue the browsing/work App1 (Server1) or App2(Server2)?)
>
> I guess my thread's title is not really relevant anymore because this code
> doesn't literally "pass" an object from one webapp to another running on two
> different servers...
> What I'm doing here is "redirecting from a servlet to an exterior URL using
> a POST".
> I'm not really displaying "something user specific / session specific" but
> Casper's comments are very interesting and may prove useful in the future
> for me.
My comments and suggestions are certainly relevant if one is trying to
accomplish something that needs to be secure (the user can't manipulate
the parameters/results to gain unauthorized access or escape payment but
still receive an item).
>
> Thanks again :)
> Best regards.
>
>
>
> --
> View this message in context: http://tomcat.10.n6.nabble.com/Pass-an-object-from-one-Webapp-to-another-on-two-differents-servers-tp4985870p4986091.html
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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
Re: Pass an object from one Webapp to another on two differents
servers
Posted by Léa Massiot <lm...@orange.fr>.
(Warning: there is some "raw text" in this post.)
Hello Casper. Hello list.
Thank you for your answer and your advices.
Here is some interesting litterature related to my problem:
"Redirecting from a servlet to an exterior URL using a POST"
http://www.mail-archive.com/servlet-interest@java.sun.com/msg49110.html
Which led me to write a programmatic POST using this code:
"How to use HttpURLConnection POST data to web server?"
http://www.xyzws.com/Javafaq/how-to-use-httpurlconnection-post-data-to-web-server/139
And, in "SERVLET_2", I replaced the code (see my first post in this thread)
with this one:
I guess my thread's title is not really relevant anymore because this code
doesn't literally "pass" an object from one webapp to another running on two
different servers...
What I'm doing here is "redirecting from a servlet to an exterior URL using
a POST".
I'm not really displaying "something user specific / session specific" but
Casper's comments are very interesting and may prove useful in the future
for me.
Thanks again :)
Best regards.
--
View this message in context: http://tomcat.10.n6.nabble.com/Pass-an-object-from-one-Webapp-to-another-on-two-differents-servers-tp4985870p4986091.html
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Pass an object from one Webapp to another on two differents servers
Posted by Casper Wandahl Schmidt <ka...@gmail.com>.
Hi Léa
Please see comments inline
Med venlig hilsen/Kind regards
Casper W. Schmidt
Den 30-08-2012 11:16, Léa Massiot skrev:
> Hello Casper,
>
> Thank you for your answer. What you are explaining totally makes sense.
>
> The "doPost()" method of "SERVLET_2" ("WEBAPP_2") ends up with a
> "sendRedirect()" method call
> which redirects to "j1.jsp", a JSP in the first webapp ("WEBAPP_1").
>
> Let's forget about sessions and passing whole objects from one webapp to
> another.
>
> What I rather need is pass at least one parameter from the servlet
> "SERVLET_2" to the JSP "j1.jsp".
> I could pass these parameters using the "GET" method, for example here with
> the parameter "result":
note: The list (Or my mail client?) has stripped the "graphic" but I
checked it in the nabble thread version (for anyone interested go check
it there too)...
If you want to display something user specific / session specific you
need something else but result=ok, perhaps id=SOME-ID, where SOME-ID is
some id on server2, then Server1/JSP1 can contact Server2 giving this id
as a parameter, so that Server2 can give the correct result (ie. ok). If
you simply want ok/fail in JSP1 then it should be okay to simply do what
you do (as long as Server2 and JSP1 agrees on the possible results),
just be aware that a user can fake that URL - simply put
http://<IP_1>/<WEBAPP_1 name>/j1.jsp?result=ok in your browser and
j1.jsp will handle the request the same way as redirects from Server2
(so don't use Servlet_2 for anything "confidential" ie. login-checking).
If you want to be able to do it securely (ie. for login-checking) you
need the extra step I mentioned in my first post (Server1 contacts
Server2 by itself to get the result of what happened over there simply
giving some unique id that Server2 supplied in the redirect URL to the
client).
>
> And retrieve this parameter in "j1.jsp" like this:
note: same as above...
>
> But I wish I could pass that parameter using the "POST" method...
> but as far as I've read, it looks like it's not possible...
No it is not possible, what you do is simply sending an URL to the
client, asking it to make a request to that URL next/instead so POST is
not an option here (admitted, my http 1.1 spec knowledge is rusty and
flawed, but I'm quite sure on this).
>
> Best regards.
>
>
>
> --
> View this message in context: http://tomcat.10.n6.nabble.com/Pass-an-object-from-one-Webapp-to-another-on-two-differents-servers-tp4985870p4986038.html
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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
Re: Pass an object from one Webapp to another on two differents
servers
Posted by Léa Massiot <lm...@orange.fr>.
Hello Casper,
Thank you for your answer. What you are explaining totally makes sense.
The "doPost()" method of "SERVLET_2" ("WEBAPP_2") ends up with a
"sendRedirect()" method call
which redirects to "j1.jsp", a JSP in the first webapp ("WEBAPP_1").
Let's forget about sessions and passing whole objects from one webapp to
another.
What I rather need is pass at least one parameter from the servlet
"SERVLET_2" to the JSP "j1.jsp".
I could pass these parameters using the "GET" method, for example here with
the parameter "result":
And retrieve this parameter in "j1.jsp" like this:
But I wish I could pass that parameter using the "POST" method...
but as far as I've read, it looks like it's not possible...
Best regards.
--
View this message in context: http://tomcat.10.n6.nabble.com/Pass-an-object-from-one-Webapp-to-another-on-two-differents-servers-tp4985870p4986038.html
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Pass an object from one Webapp to another on two differents servers
Posted by Casper Wandahl Schmidt <ka...@gmail.com>.
Without being a Tomcat expert I don't think that is possible like that.
On the other hand it looks just like what happens when you buy something
online 1. You go to a webshop and put something in your cart, 2. you are
redirected to a payment site (ie. quickpay.com), 3. after payment you
are redirected back to the webshop and confirmation is showed.
What really happens (as far as I remember) is, that when you redirect
from server1 you give as parameter what is called a return URL, this is
the address of the page shown in step 3 above (confirmation). Part of
this URL is some variable that enables you to tell who the user is (ie.
sessionID). When server2 is finished it will send a redirect to the
client, redirecting it to the return URL server1 gave it. Part of the
redirect URL send by server2 is another variable (callback/status) that
enables server1 to make a request directly to server2 to fetch whatever
it needs (ie. xml markup or a simple string). This last step is used by
webshops to check against the payment site that the user actually did
put in correct creditcard details and not just cancelled, before
returning to the confirmation page.
I think what you are looking for is exactly that. F1 submits to Server_2
(perhaps including session ID or something else uniquely identifying the
user). When Servlet_2 completes it redirects to JSP_1 giving some URL as
a parameter (ie.
redirect-url-to-Server_1.com?callback=some-url-with-unique-identifier).
Then JSP_1 can open a connection and retrieve the user-specific
message/object (if the object can somehow be transfered, normally this
requires either Serializable interface, some kind of xml markup to
recreate the object or something else like that) .
Hope it helps you out!
Med venlig hilsen/Kind regards
Casper W. Schmidt
Den 29-08-2012 13:30, Léa Massiot skrev:
> I posted mistakenly in the "Tomcat" forum instead of here "Tomcat-User" (I
> just moved my thread).
> Can you help me?
> Best regards.
>
>
>
> --
> View this message in context: http://tomcat.10.n6.nabble.com/Pass-an-object-from-one-Webapp-to-another-on-two-differents-servers-tp4985870p4985967.html
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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