*
The moose likes Struts and the fly likes submit form to external url using struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "submit form to external url using struts" Watch "submit form to external url using struts" New topic
Author

submit form to external url using struts

vishal Mestri
Greenhorn

Joined: Sep 05, 2012
Posts: 14
Hi All,

I am back with one more question.

I am using struts 1.2.7 version and working on application which is going to call payment gateway url.

Hence, as a security reason, I have to send all data to payment gateway using POST method.

I am not sure , how I can achieve same using struts.

Currently , what I have done is i have created simple jsp(shown below) on which I am first putting all parameters in hidden and set payment gateway url dynamically as action in form tag using normal scripting , and on body load, I am submitting the form.

Can I do the same using struts.

I tried to search on google, but what answers I got is <logic:redirect>. But I think , it will not be helpful in submitting form using post.

Kindly help me with sample code or please confirm that it is possible or not possible.

jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

Hi Vishal,

I think you should call the payment gateway from Struts action or class where you business logic resides.Second thing its the same in struts as in servlet.

Please refer to following links which uses httpclient and java.net.url to send request to paypal.

Regards
Jatan
vishal Mestri
Greenhorn

Joined: Sep 05, 2012
Posts: 14
Hi jatan,

thank you very much for replying to my different posts..

In this case, my issue is when I have to call payment gateway, control is going to be transfered to payment gateway site.
Hence I think calling payment gateway from server side , will not be possible. i.e. using java.net.URL which you are suggesting.

Please let me know if i am thinking on right track or not.

Regards,
Vishal
Ashwini Kashyap
Ranch Hand

Joined: Aug 30, 2012
Posts: 90
Hi Vishal,

For calling external links from struts application like any payment gateway, you are on the right track.
Make use of java.net API or HttpClient API.

Thanks and Regards,
Ashwini Kashyap | akashyap@infocepts.com | www.infocepts.com
vishal Mestri
Greenhorn

Joined: Sep 05, 2012
Posts: 14
Hi Ashwini,

thanks for reply.

But what I tried to convey in earlier email was I can not use java.net.URL or Http Client api, as control has to be transferred to Payment gateway pages.

I think it would not be possible that first I call payment gateway url from server side using HTTP Client api. If I do that, i will not be able to transfer control to payment gateway.

I hope , you understand what I want to convey.

Regards,
Vishal
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

Hi vishal,

I think you will be able to do it, As once the request is generated through your servlet wiht httpclient or url.net package it will go to the payment gateway so it will transfer the controll to payment gateway. try to check it with the test page provided by the payment gateway. They provide the test page where you can check the proepr integration with the payment gateway with dummy card number.

Once the payment has been made the payment gateway will return the necessary data back to your application which you need to store it in your database.

Regards
Jatan
Ashwini Kashyap
Ranch Hand

Joined: Aug 30, 2012
Posts: 90
Yes Jatan is right. Once the transaction is successfull, it returns some data back with which you can verify the success or failure of the transaction.

Thanks and Regards,
Ashwini
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: submit form to external url using struts