struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Evans <dsev...@berndtgroup.net>
Subject Re: How to POST data to an external site from an action?
Date Tue, 02 May 2006 18:37:01 GMT
Here's a quick connect using standard java (not tested):

java.net.HttpURLConnection connection;
java.net.URL url;

    try {
       // Create new URL and connect
       url = new URL("http://www.test.com/test.cgi");
       connection = (HttpURLConnection) url.openConnection();
       // Setup HTTP POST parameters
       connection.setDoOutput(true);
       connection.setDoInput(true);
       connection.setUseCaches(false);
	
       String queryString = "myParm1=test&myParam2=test2";

       // POST data
       OutputStream out = connection.getOutputStream();
       out.write(queryString);
       out.close();
   }
   catch (Exception e1) {
       System.out.println("Error:" + e1.toString());
   }


n Tue, 2006-05-02 at 18:42 +0200, Martin Kindler wrote:
> Hi all,
> 
> I'm kind of stuck with a little problem. perhaps someone can help!
> 
> I want to include a payment service into my Struts Action 1.2.x based shop.
> The payment service needs the information via http POST. The user (my
> customer) will authorize the transaction on the site of the payment service.
> After finishing he will press a "back"-button which calls my shop again.
> 
> I could put a form containing the necessary data for the payment service on
> my shop site and on submit everything would be fine. But as I will support
> more than one payment service I would like to not include all the data in
> the JSP page where they could be seen in the source.
> I would instead like to have a button "pay by payment service x" which calls
> an action that creates the POST data and sends them to the payment service
> redirecting my customer to its site.
> 
> as a picture:
> 
>  payByPaymentService.do?id=<paymentserviceid>
>       |
>       |  (the product data are stored in the session)
>       v
>  payByPaymentServiceAction.execute()
>       |
>       | (generate the POST data)
>       v
>  http://www.paymentservice.cgi
> 
> How can I do this?
> 
> Martin
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message