By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,554 Members | 1,146 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,554 IT Pros & Developers. It's quick & easy.

Sending a GET-string

P: n/a
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
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a

"Rick" <as******@hotmail.com> wrote in message
news:3f*********************@news.xs4all.nl...
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


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

Regards,

Silvio Bierman

Jul 17 '05 #2

P: n/a
Thanks for your fast reply! I tried
url = new java.net.HttpURLConnection( ... );
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
Jul 17 '05 #3

P: n/a

"Rick" <as******@hotmail.com> wrote in message
news:3f*********************@news.xs4all.nl...
Thanks for your fast reply! I tried
url = new java.net.HttpURLConnection( ... );
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


It goes something like this:

URL url = new URL("http://bla.bla.com/bla");
HttpURLConnection con = (HttpURLConnection)servlet.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
//add headers on con
OutputStream out = con.getOutputStream(); //request is committed, headers
are fixed
//write the request body
out.close();
InputStream in = con.getInputStream();
//read the response body
in.close();
//done

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

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

Regards,

Silvio Bierman
Jul 17 '05 #4

P: n/a
Thanks for taking time! It's getting clear now.

Rick
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.