wood burning stoves 2.0*
The moose likes Servlets and the fly likes Communication between Two web application Problem. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Communication between Two web application Problem." Watch "Communication between Two web application Problem." New topic
Author

Communication between Two web application Problem.

Jefrey Valencia
Greenhorn

Joined: Apr 08, 2011
Posts: 7

Hi, new to this forums and hopefully my post is clear enough for you guys to help me.

I have a problem on an application my new boss wants me to create. The application that I have to create must communicate with another web application. So using MVC design pattern I have something like this in my model class.





With this code I was able to simulate an Http Request to the remote Web application; however, the design only allows the remote web application to send its response to URL mapped "ReturnURL". (The Remote Web application just sends an http request to the given URL)

Is there a way to Get the data to my model class so my local application can process it instead of displaying it to a web page immediately? Also I would like to add that I really y don’t have any control on the remote application so please give me any advice for this situation.



Thanks in advance

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Jefrey Valencia wrote:however, the design only allows the remote web application to send its response to URL mapped "ReturnURL". (The Remote Web application just sends an http request to the given URL)

This is the part that doesn't make sense. Responses aren't sent to URLs; they are returned as a result of a request. So if you are making a request, and the target web service responds to that request, it will come to you as the response to your request.

Or are you using the term "response" incorrectly?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3817

And welcome to JavaRanch, Jefrey Valencia


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Jefrey Valencia
Greenhorn

Joined: Apr 08, 2011
Posts: 7
Hi and Thanks to the reply.


Actually the "ReturnURL" will allow the remote web application to send detailed result of the application.


So this is my current process.

1) I have a LOCAL web application with 2 JSP Pages

- form.jsp - contains a form that post data to the REMOTE web application. This includes the "ReturnURL" parameter whose value is "http://localhost:8080/Test2/result.jsp"
- result.jsp - contains a code that just prints the given request parameters. Example would be <%= request.getParameter("Result")%>

2) The REMOTE web application has 1 JSP visible to me.
- procs.jsp - This the page where my form.jsp post its data. After processing my data it would return a Web Page that tells me if the transaction was a success or not. After 5 seconds the web page reloads and goes to the LOCAL web application result.jsp .



(LOCAL)form.jsp -----> (REMOTE) proc.jsp ---> (LOCAL)result.jsp


Note:

The proc.jsp page contains this javascript code that reloads that redirect the page to the result.jsp






Again I really appreciate your replies.


amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 511
Hi,
Based on your sequence of event I guess you should not reload the webpage as mentioned in

After 5 seconds the web page reloads and goes to the LOCAL web application result.jsp .


Instead from your "form.jsp" initiate the HttpClient request to the remote webapplication. I am not sure if you need to pass "ReturnURL" as it will always pass the response back to the URI from where the request has been originated. (Please note that writing Java code in the JSP is bad idea so you shall need to refactor app)
Once you get response back in "form.jsp" you need to parse it to see what is the transaction status. Once you know the status you can forward the request using RequestDispatcher to "result.jsp". This does not need you to reload the webpage after 5 seconds.
Hope this helps.
Regards,
Amit
Jefrey Valencia
Greenhorn

Joined: Apr 08, 2011
Posts: 7
Thanks amit punekar for the advice.


Here are a few more code snippets to help you understand my problem.


Code Sample of form.jsp



Code of proc.jsp (Shown in view source from browser)



Code Sample of result.jsp



So this is how the process currently work.

1) The user use the form in "form.jsp"
2) "form.jsp" post the data to "https://www.remote.com/payment/proc.jsp"
3) "proc.jsp" return a web page that tells if transaction is successful. It also has a built in timer that will direct the page to the
ReturnURL that is currently set to "https://www.local.com/payment/result.jsp"
4) "result.jsp" will print the request parameters.


What I need.
1) Get the request parameters being sent to "result.jsp". Using the code in my very first post I was able to retrieve the HTML code of "proc.jsp". But "proc.jsp" has a built in script that redirects it to the submitted ReturnURL. This is fine if I wanted to show the results given by the REMOTE web app but I want to do some additional processing in my LOCAL web app.
2) So can anyone help me extend/modify the code in my first post to be able to receive the request parameters that is bound for the ReturnURL = "result.jsp".

Notes:
1) ReturnURL is a required parameter of the proc.jsp
2) I have no control on the implementation of the REMOTE web app.


Thanks in advance.
Jefrey Valencia
Greenhorn

Joined: Apr 08, 2011
Posts: 7
Does anyone have any other ideas?
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 511
Hello,
For you to be able to do this

somone should call your JSP with these request Parameter - Either through Query String or form submission.
I think "proc.jsp" is doing that but when we look at the code of "proc.jsp" there is this timer function which invokes "returnToMerchant.submit();". I tried locating the form named "returnToMerchant" but unsuccessful.

Hope this helps you analyzing your problem.

regards,
Amit
Jefrey Valencia
Greenhorn

Joined: Apr 08, 2011
Posts: 7
Yeah I guess you are right. I wonder how the remote web app is able to use "returnToMerchant.submit()" without sending it to my browser. Ill look into that thanks.
 
wood burning stoves
 
subject: Communication between Two web application Problem.
 
Similar Threads
Apache HttpClient posing trouble
Logging in with HttpClient from Apache
Login and Download file over https
Apache HttpClient - no response after executing post method
Using Commons to access URL