The moose likes Java Micro Edition and the fly likes Problems with HttpConnection Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Mobile » Java Micro Edition
Reply Bookmark "Problems with HttpConnection" Watch "Problems with HttpConnection" New topic
Author

Problems with HttpConnection

Alex Dean
Greenhorn

Joined: Dec 16, 2000
Posts: 4
Sorry to go all technical, but I'm having real probs. with the Motorola J2ME's HttpConnection code (on a dial-up connection, if that's relevant). I'm writing a program which sends data to be processed by a Web-based CGI script. Basically, my program hangs when the HttpConnection is asked to switch from the Setup stage to the Connected stage - let me explain:
HttpConnection c = (HttpConnection)Connector.open(queryURL);
c.setRequestMethod(HttpConnection.POST);
// Code makes it here.
is = c.openInputStream();
// Code doesn't reach here.
There's no feedback like exceptions to the console, and according to my "Connected To ..." Windows dialog box, no bytes have been sent out by my computer. I'm at a loss - even setting queryURL to something like "http://www.yahoo.com" (and removing the POST command) doesn't work. Is J2ME's HTTP connection code broken? Am I being really stupid? Is there some networking config. file I need to edit or configure?
Eric Giguere
Ranch Hand

Joined: Oct 25, 2000
Posts: 170
Likely a bug. Have you tried running the same code in Sun's MIDP emulator?
Eric


Eric Giguere
Author/Co-Author of: Mobile Information Device Profile for Java 2 Micro Edition: Professional Developer's Guide, Java 2 Micro Edition: Professional Developer's Guide and PalmTM Database Programming: The Complete Developer's Guide
Alex Dean
Greenhorn

Joined: Dec 16, 2000
Posts: 4
Yep,
It's a Motorola-specific problem. The HttpConnection.POST should have been HttpConnection.GET, but then it worked fine with Sun's J2ME Wireless Toolkit. Either Motorola's code is buggy, or the SDK doesn't like being wired into Java 2 JDK 1.3 (it's meant to use 1.2, I think).
Incidentally, there's a pretty good article on the kind of stuff I was doing at: http://developer.java.sun.com/developer/technicalArticles/wireless/midpnetwork/
Thanks,
Alex
yufeng
Greenhorn

Joined: Dec 26, 2000
Posts: 2
Change your URL "www.yahoo.com" to its ip address, it will work.
It is because MotoSDK emulator doesn't provide DNS lookup emulation.
-yu
 
 
subject: Problems with HttpConnection
 
developer file tools