• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Communication between Two web application Problem.

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to JavaRanch, Jefrey Valencia
 
Jefrey Valencia
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.


 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anyone have any other ideas?
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Hug your destiny! And hug this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic