How to send data to another site, get response, redirect and get new response

Dear all,
I've to write a Java EE application that have to become an interface to a payment platform. The protocol require to send a POST string containing some information (including an error and response page) to an external host, get the response and redirect the user to another host using the previous response. When the user ends the transaction the host redirect the user to my error or response page.
For the moment my user access to my application using glassfish REALM authentication. After that I write the following code:
public void paymentPrepare() throws UnsupportedEncodingException, IOException {
   String postUrl = "https://test.payment.test/init/http";
   HttpPost postRequest = new HttpPost(postUrl);
   String id = "99999999";
   String password = "99999999";
   String action = "4";
   String amt = "1.00";
   String currencycode = "978";
   String langid = "ENG";
   String responseurl = "http://myhost:8080/EMBOWorkshop/secure/response.xhtml";
   String errorurl = "http://myhost:8080/EMBOWorkshop/secure/error.xhtml";
  trackid = "TRCK0001";
  udf1 = "Descrizione";
   StringEntity postParamsEntity = new StringEntity("id=" + id
   + "&password=" + password
   + "&action=" + action
   + "&amt=" + amt
   + "&currencycode=" + currencycode
   + "&langid=" + langid
   + "&responseurl=" + responseurl
   + "&errorurl" + errorurl
   + "&trackid" + trackid
   + "&udf1" + udf1);
  postParamsEntity.setContentType("application/x-www-form-urlencoded");
  postRequest.setEntity(postParamsEntity);
   DefaultHttpClient httpClient = new DefaultHttpClient();
   // Execute the HTTP POST
   System.out.println("Executing HTTP Post...\n");
   HttpResponse response = httpClient.execute(postRequest);
   // Check the HTTP status of the post.
   if (response.getStatusLine().getStatusCode() != 200 && response.getStatusLine().getStatusCode() != 201) {
   throw new RuntimeException("Failed: HTTP error code: "
   + response.getStatusLine().getStatusCode());
   // Create a reader to read in the HTTP post results.
   BufferedReader br = new BufferedReader(
   new InputStreamReader((response.getEntity().getContent())));
   // Read in all of the post results into a String.
   String output = "";
   Boolean keepGoing = true;
   while (keepGoing) {
   String currentLine = br.readLine();
   if (currentLine ==
null) {
  keepGoing = false;
   } else {
  output += currentLine;
   System.out.println("Raw string result: \n" + output);
The previous code works fine. I receive the response. But now I don't know how to continue. How can redirect the user to another site, and when the payment is finished, receive the response? Another question is, the user authenticate himself to access to the application. When the user will redirect to an external site, the glassfish session permits to get the response from the other host without require a new authentication?
For the moment I don't know how to redirect the user, but I tried to write this method to obtain the last response:
  public void getResponse(HttpServletRequest request, HttpServletResponse response) {
  paymentId = request.getParameter("paymentid");
  result = request.getParameter("result");
  auth = request.getParameter("auth");
   ref = request.getParameter("ref");
  traind = request.getParameter("tranid");
  trackid = request.getParameter("trackid");
  udf1 = request.getParameter("udf1");
  responsecode = request.getParameter("responsecode");
Is it correct?
Thanks

Now I'm able to redirect the user to the other page:
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
externalContext.redirect("http://stackoverflow.com");
Now the problem is: once the user has finished to pay, the other site redirect the user to my site using one of the two JSF page I prepared for error or response like the following:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./index.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:fn="http://java.sun.com/jsp/jstl/functions"
                >
    <ui:define name="content">
        <center>
           An error occurred during  transaction
            #{participantBean.auth}<br />
            #{participantBean.responsecode}
        </center>
  </ui:define>
</ui:composition>
So, how can I get the GET parameters that the other host sent to me during the redirection?

Similar Messages

  • HT204350 Incorrect link to "OS X: How to migrate data from another Mac using Mountain Lion and earlier"

    Incorrect link to "OS X: How to migrate data from another Mac using Mountain Lion and earlier". Should be http://support.apple.com/kb/HT6025

    I think the OP is saying OS X: How to migrate data from another Mac using Mountain Lion and earlier (which should be a link to HT4889) just links back to OS X: How to migrate data from another Mac using Mavericks (HT5872).
    It does indeed do that, & HT4889 seems to be MIA.

  • How to send data back to publishing stream

    Hi,
    Environment: ActionScript3.0, FMS, Flash Project created in Flash Develop
    How to send data back to publishing stream? I need to send data back to publishing stream.
    Using NetStream.send() we can send data to subscribers but is it possible to send data from subscriber back to publisher using any NetStream method.
    One other solution to this is remoteSharedObject, but if it is possible with NetStream class then let me know.
    Thanks

    There are a number of ways to extract data from CRM On Demand including:
    * Export - manual process, generate CSV file containing CRM On Demand data
    * List/Analytics - manual process, export the contents of a report of list to a CSV
    * Web Services - programmatic, develop an application that queries for data within CRMOD
    * Integration Events - programmatic, use workflow to trigger event creation and then poll for events to know when an operation occurs on a record (i.e. Insert of new Account record)
    As for getting that data into another system, that will depend on the system and the methods available for inserting data that it makes available.
    Hope this helps.
    Thanks,
    Sean

  • How to send data to RFC Destination(RFC SENDER Adapter)

    Hi ,
    Scenario:  R/3 Backendà RFC Sender Adapterà XIàsome other system.
    I have configured the RFC destination (of the type TCP/IP) at R/3 System and have registered the Program ID (specified in the RFC destination) in the XI server and using it in the configuration parameters of the RFC Sender Adapter.
    Problem: I do not know how I can send data to the RFC destination. (Should I use a report program/ ABAP Function Module?) Can anybody provide me with a sample code of Report Program/Function module (whichever is required), how to send data to the RFC Destination, so that it may be picked up by my RFC Sender Adapter.
    Thanks and Regards,
    Siva Maranani

    I have one query for you that
    I am trying to develop a scenario in SAP XI
    SAP R/3 ( RFC function module) sends a synchronous request to the XI and SAP XI will send this request to a third party web application using HTTP receiver adapter.
    I am able to send the data/message and it is successfully received at the third party web application.
    But I am facing one issue that I am unable to receive any message/data in my RFC module back.i have seen in sxmb_moni that the two messages are displayed in successfuly processed but in SAP R/3 side nothing get happedned
    Can you tell me how to use some waiting mechanism in function module to wait for the response from SAP XI.
    Regards
    Gopesh

  • Can a vi. send data to another .vi when ONLY the internet is between?

    I seem to have hit a hurdle.
    - I have one computer behind a Firewall at a university. This computer has a MIO-16E card in it. No administrative privileges to run datasocket server.
    - I have another computer(laptop)with an E series MIO that I have full privileges on, but project requirements only allow me to find wireless connection points so there is only the internet as a medium between the two.
    - If possible, I would like to pass a one way data stream from the university(UT).vi side to the Laptop .vi. By I could accept the dataflow in the other direction.
    Things I have tried: I can do Remote Panel where the UT machine controls the laptop (good); but, if scenario is switched, the laptop cannot use Remote Panel to control the UT .vi. Of course web browsers and User interfaces do very little for me since the DAQ and control signals will be unmanned.
    If someone has experience on how to make one .vi can send data to another .vi using just the internet, I would truly appreciate some advice. And, to be honest, I am solely a hardware individual and have not figured out how/what to setup for this experiment.
    Thanks for your time.

    SDGhwrtech wrote:
    I seem to have hit a hurdle.
    - I have one computer behind a Firewall at a university. This computer has a MIO-16E card in it. No administrative privileges to run datasocket server.
    - I have another computer(laptop)with an E series MIO that I have full privileges on, but project requirements only allow me to find wireless connection points so there is only the internet as a medium between the two.
    - If possible, I would like to pass a one way data stream from the university(UT).vi side to the Laptop .vi. By I could accept the dataflow in the other direction.
    Things I have tried: I can do Remote Panel where the UT machine controls the laptop (good); but, if scenario is switched, the laptop cannot use Remote Panel to control the UT .vi. Of course web browsers and User interfaces do very little for me since the DAQ and control signals will be unmanned.
    If someone has experience on how to make one .vi can send data to another .vi using just the internet, I would truly appreciate some advice. And, to be honest, I am solely a hardware individual and have not figured out how/what to setup for this experiment.
    Thanks for your time.
    If your labtop has a well known IP address/name you could always create a little TCP/IP server in LabVIEW and run it on that computer. Then have the university computer regularly try to connect to that labtop computer and on success start streaming the data you want to the server. The server then will receive the data and do something with it.
    Take a look at the VI examples in examples/comm/tcp.llb. Especially the Simple Data Client.vi and Simple Data Server.vi might be interesting for you.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to send data from internal table to the shared folder in ABAP

    Hi experts,
             My requirement is to transfer data from a file to shared folder. i just did reading data from a file to a internal table. Now i want to send this internal table data into a shared folder which is  "
    xxx\y\z....".
    I do not have any idea on how to send data from internal table to the shared folder path.
    can anybody please help me out how to do this?
    Thanks & Regards
    Sireesha.

    Where that folder is located, its on presentation server i.e. desktop or application server.
    If its on presentation server, use FM GUI_UPLOAD.
    If its on application server, then use DATASET functions. Have a look at below link.
    [File Handling in ABAP|http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm]
    I hope it helps.
    Thanks,
    Vibha
    Please mark all the useful answers

  • How to send data to bam data object through java code

    how to send data to bam data object through java code

    I've made a suggestion in other thread: https://forums.oracle.com/thread/2560276
    You can invoke BAM Webservices (Using Oracle BAM Web Services) or use JMS integration using Enterprise Message Sources (http://docs.oracle.com/cd/E17904_01/integration.1111/e10224/bam_ent_msg_sources.htm)
    Regards
    Luis Fernando Heckler

  • IDOC :: how to send data from Custom Infotype in SAP HR to third party

    Hi,
    I have created one custom Infotype by number 9020. How to send data from this infotype to third party system and also change pointers need to trigger for this infotype.
    Please help me in doing it.
    I am using one Custom Message type ZTALENT and Custom Idoc Type ZTALENT.
                                                                                    ZTALENT                        Talent Management                                                                               
    5  E1PLOGI                        Header for an HR Object (Master Data or Organizational Data)                                                                               
    5  E1PITYP                        HR: Transported Infotypes and Subtypes for an Object                                                                               
    ZPUSER                         User base Data File                                          
                    ZPERSON                        Personal Information File Segment                            
                    ZPOST                          Position File                                                
                    ZOPE                           Overall Performance                                          
                    ZPWORK                         Outside Work Experience                                      
                    ZPEDUC                         Education Details of Employee                                
                    E1P0000                        HR: HR Master Record Infotype 0000 (Actions)                 
                    E1P0001                        HR: HR Master Record Infotype 0001 (Org. Assignment)         
                    E1P0002                        HR: HR Master Record Infotype 0002 (Personal Data)           
                    E1P0016                        HR Master Record: Infotype 0016 (Contract Elements)          
                    E1P0022                        HR Master Record: Infotype 0022 (Education)                  
                    E1P0023                        HR Master Record: Infotype 0023 (Other/Previous Employers)   
                    E1P0041                        HR Master Record: Infotype 0041 (Date Specifications)        
                    E1P0105                        HR: HR Master Record Infotype 0105 (Communications)       
                   ZE1P9020
                    ZPLANG                         Language Details                                             
                    ZACTION                        Actions Changes            
    Regards,
    Krishna

    Hello Shankar,
             Technically TEMSE files are read by calling the following 3 function modules in sequence,
                  1) RSTS_OPEN_RLC or RP_TS_OPEN: open the temse object
                  2) RSTS_READ : read the object
                  3) RSTS_CLOSE: close the object
    Regards,
    Rajesh

  • Why when I try to re download my music it says this device is already associated with another device and I have so many days to re download my music back? How do I get around this and get my music back?

    Why when I try to re download my music it says this device is already associated with another device and I have so many days to re download my music back? How do I get around this and get my music back?

    It is telling you that the device has been associated with another Apple ID. Once an Apple ID has been associated with a device, there is a 90-day waiting period before another Apple ID can be associated with that device. Here is a Support Article that explains the 90-day waiting period:
    iTunes Store: Associating a device or computer to your Apple ID
    Cheers,
    GB

  • How to send message to another ipod user

    Hello Team ,
    Please help me to understand , how to send message to another user of Ipod
    I am having ipod 4G touch , So please guide me on this .
    also Can we pair ipod to any bluetooth head set  , Curretnly i having Samsung strero phone head phone model no SBH650 .
    Please help me ....
    Thank you
    Regards
    Mahesh

    Hi
    Please check FM <b>TH_POPUP</b>
    Is this what you require ?

  • How can I cancel the storage plan I just bought and get a bigger plan?

    How can I cancel the storage plan I just bought and get a bigger plan?

    I quote:
    'If you purchase a higher-tier storage plan for your iCloud account to replace your existing storage plan (for example, a 20 GB plan to replace a 10 GB plan), the existing plan will be canceled and you will receive a prorated refund for the time remaining. The new storage plan is applied to your iCloud account and the annual payment date is updated to reflect the purchase date for the new plan.'
    So just purchase the new storage level and it will sort itself out automatically.

  • I purchased a CD on itunes and it charged automatically to the card under the account, but I wanted it to charge to my gift card.  How do I get a refund and get the music to charge to my gift card instead?

    I purchased a CD on itunes and it charged automatically to the card under the account, but I wanted it to charge to my gift card.  How do I get a refund and get the music to charge to my gift card instead?

    Hi TKCDM1!
    You should try to get this purchase onto your iOS device by using the suggestions in the following article:
    Downloading past purchases from the iTunes Store, App Store, and iBooks Store
    http://support.apple.com/kb/ht2519
    Thanks for being a part of the Apple Support Communities!
    Regards,
    Braden

  • I cannot install adobe reader. I get so far and get the message "Error 1324. The oath All folders or the volume is invalid. Please enter it again" can you help?

    i cannot install adobe reader. I get so far and get the message "Error 1324. All folders or the volume is invalid. Please enter it again" can you help?

    We need to know if any registry settings are causing this error.  Please follow these instructions:
    from Windows Start | Search: type regedit and hit Enter; you will see a window like this
    now click on the little arrow ▹ left from HKEY_CURRENT_USER
    Next click the arrow ▹ beside Software, then Microsoft, then Windows, then CurrentVersion, then Explorer, then click on User Shell Folders
    all entries on the right side should start with %USERPROFILE%
    If you have anything different, this may be the cause for the install failure.
    Now you need to repeat the same thing for another key:
    ▹ HKEY_LOCAL_MACHINE ▹ Software ▹ Microsoft ▹ Windows ▹ CurrentVersion ▹ Explorer ▹ User Shell Folders
    Here all entries should start with %PUBLIC% or %ProgramData%.  If you have anything different, this may also be the cause for the install failure.

  • My laptop is HP Pavilion DV6 1319TX (2 yrs old),it is getting heated up and getting strucked up.

    My laptop is HP Pavilion DV6 1319TX (2 yrs old),it is getting heated up and getting stucked up.can any one help ...
    O.S. Installed :Windows 7 vista
    No upgradtion of software or no upgradation of BIOS or no upgradation of hardware elements since i bought .

    After 2-3 years laptops may need to have the cooling fan and heatsink area cleaned out and have new cooling paste applied on the processor. I just did this on my own laptop which will be 3 years old in September. It is a fairly advanced procedure. We can provide material that will tell you how to do it, but more likely you need to find a local computer shop to perform the task. Expect to pay $50-100.

  • I am having trouble connecting to my network all of a sudden. It is not an issue with the service/router. I keep getting kicked off and getting a ! in my airport... anyone know what's up with this?

    I am having trouble connecting to my network all of a sudden. I am able to connect to other networks but not my own. It is not an issue with the service/router because other devices connect fine. I keep getting kicked off and getting a ! in my airport. Last time it happended I called apple and the suggested I wipe my HD and reinstall everything. I did and it did not work. One day I turned my laptop on and it connected no problem. Now it has kicked me off again. I tried resetting my IP address but that does not work either! Has anyone had this problem?

    Try this:
    Apple menu / System Preferences / Network.
    Click Location: and select Edit Locations..
    Click + (plus sign), and enter a name for the new location - anything will do.
    Apply this.

Maybe you are looking for