Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: Problem with HTTPClient and getResponseBodyAsString()

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Problem with HTTPClient and getResponseBodyAsString()

    Hi,

    I'm working on interfacing with a payment portal and at some point I have to submit hashed XML to a servlet (my own). I post and get a successful response, however I do not wish to "capture" the response and output it back, but rather redirect the response (without involving the calling servlet) and put everything in an iFrame.

    My Servlet:
    try{
                 PostMethod post = new PostMethod("https://www.url.com/checkout.aspx");
                 post.addParameter("params", XMLData);
                 HttpClient client = new HttpClient();
                 int status = client.executeMethod(post);
                 String reply = post.getResponseBodyAsString();
                 out.print(reply);
             } catch (Exception e){
                 out.print("ERROR ");
                 e.printStackTrace(out);
             }

    My HTML:

    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Test</title>
        </head>
        <body style="text-align:center">
            <iframe style="border: 0px;" src="http://localhost:8084/test" width="650" height="540">
              <p>Your browser does not support iframes.</p>
            </iframe>
        </body>
    </html>

    To give you an idea, the response is an html form, that doesn't submit because the service "checkout.asp" is not available on this server, but on the originating server.

    Does anyone have an idea on how to sort this? Thanks a bunch
    Last edited by method8; April 30th, 2011 at 10:07 AM.


Similar Threads

  1. tutorial for proxyauthentication using httpclient
    By jaya in forum Java Networking
    Replies: 1
    Last Post: January 21st, 2011, 09:28 AM

Tags for this Thread