Sending a GET-string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rick

    Sending a GET-string

    Hi,

    How to send a so called GET-string from an applet to a certain IP adress?
    With a GET-string I mean that thing basic HTML can do as well. If you click
    on a save button or something on a page you often see strings like these in
    the adress field:
    "/blabla.html/?test=yes&name= ....
    That stuff is sended to some IP adress which handles the arguments (
    everything after the '?' ) and sends a page back. Basically it's just a
    hyperlink. So, maybe I should ask, how to send a string to a known IP
    adress? I don't think I can setup a client/host udp/tcp socket-thingie
    connection between the remote thing(a microcontroller with GPRS modem) so
    how to do it then?

    Greetings,
    Rick


  • Silvio Bierman

    #2
    Re: Sending a GET-string


    "Rick" <aso3rick@hotma il.com> wrote in message
    news:3fe1885d$0 $228$e4fe514c@n ews.xs4all.nl.. .[color=blue]
    > Hi,
    >
    > How to send a so called GET-string from an applet to a certain IP adress?
    > With a GET-string I mean that thing basic HTML can do as well. If you[/color]
    click[color=blue]
    > on a save button or something on a page you often see strings like these[/color]
    in[color=blue]
    > the adress field:
    > "/blabla.html/?test=yes&name= ....
    > That stuff is sended to some IP adress which handles the arguments (
    > everything after the '?' ) and sends a page back. Basically it's just a
    > hyperlink. So, maybe I should ask, how to send a string to a known IP
    > adress? I don't think I can setup a client/host udp/tcp socket-thingie
    > connection between the remote thing(a microcontroller with GPRS modem) so
    > how to do it then?
    >
    > Greetings,
    > Rick
    >
    >[/color]

    Look into class URL and (Http(s))URLCon nection. HTTP(S) has been done for
    you but it has been tucked away somewhat..

    Regards,

    Silvio Bierman





    Comment

    • Rick

      #3
      Re: Sending a GET-string

      Thanks for your fast reply! I tried
      url = new java.net.HttpUR LConnection( ... );
      But now... what to fill in for the parameter? It's maybe a stupid question
      but I'm not very familiar with url's, internet and stuff. Let's say I have
      this IP adress, "1.2.3.4", it's the IP adress of that GPRS modem thing. Now
      I want to request "test.html" . How to set-up the parameter?

      By the way, when that URL class is created is the string sended immidiatly
      or do I need to do another call before it goes?

      Thanks again!
      Rick


      Comment

      • Silvio Bierman

        #4
        Re: Sending a GET-string


        "Rick" <aso3rick@hotma il.com> wrote in message
        news:3fe18e35$0 $233$e4fe514c@n ews.xs4all.nl.. .[color=blue]
        > Thanks for your fast reply! I tried
        > url = new java.net.HttpUR LConnection( ... );
        > But now... what to fill in for the parameter? It's maybe a stupid question
        > but I'm not very familiar with url's, internet and stuff. Let's say I have
        > this IP adress, "1.2.3.4", it's the IP adress of that GPRS modem thing.[/color]
        Now[color=blue]
        > I want to request "test.html" . How to set-up the parameter?
        >
        > By the way, when that URL class is created is the string sended immidiatly
        > or do I need to do another call before it goes?
        >
        > Thanks again!
        > Rick
        >
        >[/color]

        It goes something like this:

        URL url = new URL("http://bla.bla.com/bla");
        HttpURLConnecti on con = (HttpURLConnect ion)servlet.ope nConnection();
        con.setDoInput( true);
        con.setDoOutput (true);
        con.setUseCache s(false);
        //add headers on con
        OutputStream out = con.getOutputSt ream(); //request is committed, headers
        are fixed
        //write the request body
        out.close();
        InputStream in = con.getInputStr eam();
        //read the response body
        in.close();
        //done

        This will result in a POST request. Use setDoOutput(fal se) and skip the
        outputstream part do do a GET. HttpURLConnecti on has methods to be explicit
        on the HTTP verb.

        Just from the top of my head so don't sue me...

        Regards,

        Silvio Bierman


        Comment

        • Rick

          #5
          Re: Sending a GET-string

          Thanks for taking time! It's getting clear now.

          Rick


          Comment

          Working...