|
Hello! I am writing a small Program which shall be able to update my host-ip on dyndns. Due to the Java ME restrictions, I can´t use the direct url-command like:
So I have to perform a http GET, but when I try this:
I always get a 404 Error, just what happens if you enter http://members.dyndns.org in your adress-bar. Can somebody please tell me what I am doing wrong? Thank you!!! |
|
First of all, the HttpConnection class is made specifically to handle HTTP connections, and it does so with its built-in managed features. When using a managed object such as an HttpConnection object, you're not directly controlling the low-level aspects of the connection in a traditional sense, but you can manipulate it indirectly. Just keep in mind that you are not opening a generic TCP/IP connection, but an HTTP connection :-) When you send chars to the DataOutputStream, you are actually sending a request body (not headers). At that time, the HttpConnection Class has already initiated the connection, sent the initial "GET" command and any default headers. As you can see in this line, you have already specified the URI (for the GET command) to be "http://members.dyndns.org": HttpConnection conn = (HttpConnection) Connector.open("http://members.dyndns.org"); To explicitly set an HTTP header, use the setRequestProperty method. I'll thow you an example:
Hope this helps. EDIT: By the way, you should make sure you read the InputStream as well, to read the actual response string from the update API. |
|
It would help if you could provide the full 404 error returned. |