HTTPClient: specifying url string

Discussion in 'Java' started by Dale, Nov 10, 2003.

  1. Dale

    Dale Guest

    I need a little assistance with pulling down a page using HTTPClient,
    if someone with experience has a moment...

    Name value pairs handled through NVPair are fine, but what about if I
    want to read a page normally reached like this:

    http://some.domain.com/somePath/someProggy.dll?ThisGuy&name1=value1&name2=value2

    domain = "some.domain.com";
    page = "somePath/someProggy.dll";
    formData = new NVPair[] {new NVPair("name1", "value1"),new
    NVPair("name2", "value2")};

    But where does "ThisGuy" go?

    I tried NVPair with "" and null - no-go. That emulates "ThisGuy=",
    and the page I'm going after doesn't like that.

    Thanks for reading!

    --Dale--
    Dale, Nov 10, 2003
    #1
    1. Advertising

  2. Dale

    jock Guest

    Dale wrote:
    >
    > I need a little assistance with pulling down a page using HTTPClient,
    > if someone with experience has a moment...
    >
    > Name value pairs handled through NVPair are fine, but what about if I
    > want to read a page normally reached like this:
    >
    > http://some.domain.com/somePath/someProggy.dll?ThisGuy&name1=value1&name2=value2
    >
    > domain = "some.domain.com";
    > page = "somePath/someProggy.dll";
    > formData = new NVPair[] {new NVPair("name1", "value1"),new
    > NVPair("name2", "value2")};
    >
    > But where does "ThisGuy" go?
    >
    > I tried NVPair with "" and null - no-go. That emulates "ThisGuy=",
    > and the page I'm going after doesn't like that.
    >
    > Thanks for reading!
    >
    > --Dale--


    I'm not sure about that (I worked a lot with POST method),
    but you could allocate a GetMethod object like

    GetMethod get = new
    GetMethod("http://some.domain.com/somePath/someProggy.dll?ThisGuy&name1=value1&name2=value2");

    and than do something like that

    HttpClient client=new HttpClient();
    client.executeMethod(get);

    Let me know if it work
    Cheers
    jock
    jock, Nov 10, 2003
    #2
    1. Advertising

  3. Dale

    Dale Guest

    jock <> wrote in message news:<>...
    > Dale wrote:
    > >
    > > Name value pairs handled through NVPair are fine, but what about if I
    > > want to read a page normally reached like this:
    > >
    > > http://some.domain.com/somePath/someProggy.dll?ThisGuy&name1=value1&name2=value2
    > >
    > > domain = "some.domain.com";
    > > page = "somePath/someProggy.dll";
    > > formData = new NVPair[] {new NVPair("name1", "value1"),new
    > > NVPair("name2", "value2")};
    > >
    > > But where does "ThisGuy" go?


    > GetMethod get = new
    > GetMethod("http://some.domain.com/somePath/someProggy.dll?ThisGuy&name1=value1&name2=value2");
    >
    > and than do something like that
    >
    > HttpClient client=new HttpClient();
    > client.executeMethod(get);
    >


    jock, Thanks for the advice, but I think I must be using an old
    version or something. I didn't go into it, but I create an
    HTTPConnection with a domain and port, then call the Get method with a
    page and formData. The documentation doesn't say anything about
    "GetMethod" or "executeMethod". The version I have came with a GNU
    license dated 1999 and "Copyright (c) 1996-2001 Ronald Tschalär"-
    maybe there's an update?
    Dale, Nov 11, 2003
    #3
  4. Dale

    Dale Guest

    I found the latest version at
    http://jakarta.apache.org/commons/httpclient/downloads.html

    As usual with these things, the old usable version has been picked-up
    and changed to such an extent that my old code won't run with the new
    stuff (even if I could figure out exactly what to download,
    dependencies and all). I noticed that NVPair is gone. So, one day
    when I have plenty of time, I'll think about switching over (sigh).

    --Dale--
    Dale, Nov 11, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vighnesh
    Replies:
    1
    Views:
    5,534
    Landley
    Sep 29, 2005
  2. Robert Rotstein

    specifying a query string in an href dynamically

    Robert Rotstein, Nov 25, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    405
    Garfield
    Nov 25, 2005
  3. Replies:
    0
    Views:
    440
  4. Replies:
    0
    Views:
    961
  5. nick
    Replies:
    1
    Views:
    441
    David Mark
    Feb 13, 2011
Loading...

Share This Page