• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Using PostMethod to post from a servlet without capturing the response body

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

Is there a way to avoid capturing a post reply response body?



The only output i get is if i do


But it need the output to be on https://www.somehost.com/Pay and not as output of my own servlet.

Any help appreciated.

William.
 
Sheriff
Posts: 67754
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

William Farrugia wrote:But it need the output to be on https://www.somehost.com/Pay and not as output of my own servlet.


I do not know what you mean by this.
 
William Farrugia
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello and thanks for your reply.

Well posting from a form by



and doing it via PostMethod


yields a different result. By PostMethod the response is sort of captured and I can output it with out.print, but instead I would like to open the response page on the source server rather than printing it out from my servlet. I know it's kinda strange sorry.






 
Bear Bibeault
Sheriff
Posts: 67754
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

William Farrugia wrote:but instead I would like to open the response page on the source server rather than printing it out from my servlet.


Still lost. Are you expecting to cause a browser window to open up somewhere else and display a response? Isn't going to happen. No where. No how.

What are you actually trying to accomplish?
 
William Farrugia
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's a payment gateway. They require that I post hashed XML to a web service, and the response is a secure form (with text fields for the credit card, cvv etc) that I should be able to place in an iFrame. When I output the response body as a String (from the PostMethod) I get the form properly but it doesn't submit cause the action is set to a web service that obviously doesn't exist on my server.

Should I maybe use the regular HTML form instead and just generate the XML from a JSP?

Re your question yes, I would like the response to popup in an iFrame. Sorry for the mess but I think I should probably change payment gateway provider :/
 
Sheriff
Posts: 28394
100
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William Farrugia wrote:Re your question yes, I would like the response to popup in an iFrame. Sorry for the mess but I think I should probably change payment gateway provider :/



And like Bear suggested, you can only send the response back to the place where the request came from. So if you want the response to appear in an iframe, then you have to send the request from that iframe.
 
Bear Bibeault
Sheriff
Posts: 67754
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

William Farrugia wrote:and the response is a secure form (with text fields for the credit card, cvv etc) that I should be able to place in an iFrame.


Sounds fine. Are you displaying the form in the iframe ok? If the response is a full HTML page you should have no problems. Just make sure that the request is issued from the iframe as that its the target of the response (as Paul posted).

When I output the response body as a String (from the PostMethod) I get the form properly but it doesn't submit cause the action is set to a web service that obviously doesn't exist on my server.


So when they return the form to you, the form action is not set correctly to point to a URL on their site? Are you sure that you are using their service properly?

Should I maybe use the regular HTML form instead and just generate the XML from a JSP?

You should never do anything in a JSP. JSPs are for view generation, not processing.

 
Ranch Hand
Posts: 820
IntelliJ IDE VI Editor Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A while ago, I had this same question and it nearly cost me my mind.

I posted a question on javaranch (https://coderanch.com/t/363380/Servlets/java/forward-HttpUrlConnection)
and eventually solved it.

The initial server side post returned an HTML form that I pasted back into the browser with response.getWriter().write(theReturnedHTML) and it worked!


 
Bear Bibeault
Sheriff
Posts: 67754
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
Yes, that's what we've been saying, but the point is that the request needs to come from the iframe for the response to be shown there. And it's not going to help him much if the form action isn't correct.

Still waiting for the OP to respond.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic