Page 2 of 2 FirstFirst 12
Results 21 to 31 of 31
  1. #21
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    8

    Default

    So your looking to read in all the HTML and add the entire output as one String?

    What are you going to do with this String?
    Did this post help you? Please me! :cool:

  2. #22
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #23
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    I got the point. I couldn't concatenate those strings, because of the tab space effecting. I solved my problem. It's working fine.

  4. #24
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    8

    Default

    Nice one Eranga. :D
    Did this post help you? Please me! :cool:

  5. #25
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  6. #26
    DougH is offline Member
    Join Date
    Nov 2008
    Posts
    2
    Rep Power
    0

    Default A slightly more complicated example

    If you get your own test code from the Post Office and use the link to their DLL, this would work.

    public void doPost() {
    try {
    // Construct data
    String data = URLEncoder.encode("API", "UTF-8") + "=" + URLEncoder.encode("ZipCodeLookup","UTF-8");
    data += "&";
    data += URLEncoder.encode("XML", "UTF-8") + "=" + URLEncoder.encode("<ZipCodeLookupRequest USERID=\"??????????\"><Address ID=\"0\"><Address1></Address1><Address2>6406 Ivy Lane</Address2><City>Greenbelt</City><State>MD</State></Address></ZipCodeLookupRequest>", "UTF-8");

    // Send data
    URL url = new URL("<post office API DLL LINK>");
    URLConnection conn = url.openConnection();
    conn.setDoOutput(true);
    OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
    wr.write(data);
    wr.flush();

    // Get the response
    BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    String line;
    while ((line = rd.readLine()) != null) {
    System.out.println(line);
    }
    wr.close();
    rd.close();
    } catch (Exception e) {
    e.printStackTrace();
    }

    }
    }

  7. #27
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    7

    Default

    You may want to look at the Apache httpclient code library.

    The pure Java stuff works for trivial servers, but tends to break down on real web pages from real servers. The Apache code handles "chunked" results, encoding, compression, and lots of other stuff.

    Of course, if you control both ends, the response from the Web server really should be XML so you can parse it on the client side

  8. #28
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    As fishtoprecords said look into HttpCleint,Here is the brief tutorial for HttpClient,it is very easy to use it:
    HttpClient - HttpClient Tutorial

  9. #29
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Thanks for the tutorial serjant. I've already found that when I post at the time around I start this thread. :) Did you find that any server side application related to this tutorial.

  10. #30
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    7

    Default

    Quote Originally Posted by Eranga View Post
    Hmm, I got the point. Say I want to return that String, I mean the whole String. Then what is the easiest way to do it.
    Change his loop to append the incomming string to a StringBuilder.

  11. #31
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Page 2 of 2 FirstFirst 12

Similar Threads

  1. respose with out request
    By karthikiniyan in forum Java Servlet
    Replies: 1
    Last Post: 04-09-2008, 03:06 PM
  2. How to use request Scope in Spring
    By JavaBean in forum Java Tip
    Replies: 0
    Last Post: 09-28-2007, 12:46 PM
  3. Generate XML request from web form
    By sabatier in forum XML
    Replies: 1
    Last Post: 08-09-2007, 07:53 PM
  4. Help with request.getParameter()
    By Albert in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 07-13-2007, 03:39 PM
  5. HttpServletRequest request size
    By Ed in forum Java Servlet
    Replies: 2
    Last Post: 07-02-2007, 02:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •