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.
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.
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 .
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.
Joined: Apr 08, 2011
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".
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.
Joined: Apr 08, 2011
Does anyone have any other ideas?
Joined: May 14, 2004
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.
Joined: Apr 08, 2011
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.