Aaron Johnson Now with 50% less caffeine!

Posted
30 August 2003 @ 7pm

Tagged
J2ME, Mobile Devices, XML

J2ME Recipe Browser

As an exercise, I wrote up a J2ME client for Karensrecipes.com. As I mentioned a couple days ago, it sends HTTP requests to a servlet to receive a list of recipes as XML, and then (given a specific recipe), sends another HTTP request for the recipe details (again returned as XML). It works great on the emulator, not so good on the 3650. It looks like the phone can’t establish a connection to my server, because as I tail the Apache logs, I don’t see the request come through (I do see the request when using the emulator). I’m guessing it has something to do with the default connection for Java apps on the phone. Anyone have any experience with making wireless connections on the 3650 through J2ME?

If you’re interested, you can download the application and the source:

RecipeViewer.jar
RecipeViewer.jad
RecipeViewer source


8 Comments

Posted by
Matt Liotta
2 September 2003 @ 2pm

This maybe obvious, but as I understand it all IP communications from a phone require a data plan from your provider. Does you phone have a data plan?


Posted by
AJ
2 September 2003 @ 2pm

Good point, I have the mMode “Mega” plan: http://www.attws.com/buy/consumer/pop_addon_detail.jhtml?id=400161, which allows me to browse the web and get email and stuff… that should allow simple HTTP requests right?


Posted by
wendong
3 September 2003 @ 11am

I had the similiar experience when I ported a j2me app from another phone to 3650 (t-mobile not attws). Try to do this:
Before you send a request, set the User-Agent, Content-Length etc. like this:

conn = (HttpConnection)Connector.open(serverURL);
conn.setRequestProperty( “User-Agent”, “Profile/MIDP-1.0 Configuration/CLDC-1.0″ );
conn.setRequestProperty(”Content-Language”, “en-US” );
conn.setRequestProperty( “Connection”, “close” );
conn.setRequestMethod(HttpConnection.POST);
conn.setRequestProperty(”Content-Length”, Integer.toString( msgByte.length ) );
os = conn.openOutputStream();

If this can not fix your problem, install the HttpTest to your phone (it comes with Java Wireless Toolkit). If it works, read the http codes.


Posted by
Pranav
10 August 2004 @ 11am

I am using the device 3530 and i am facing the same problem. My application is not able to communicate with my server. for making Http Connecdtion i use the following properties.

conn.setRequestProperty( “User-Agent”, “Profile/MIDP-1.0 Configuration/CLDC-1.0″ );
conn.setRequestProperty(”Content-Language”, “en-US” );
conn.setRequestProperty(”Content-Type”, “application/binary”);
conn.setRequestProperty(”Accept”, “application/binary”);
conn.setRequestProperty( “Connection”, “close” );
conn.setRequestMethod(HttpConnection.POST);
conn.setRequestProperty(”Content-Length”, Integer.toString(data.length));

but i am not able to access the server to which i am pointing.
Thre response code give me the HTTP_BAD_GATEWAY : error code 502. what it means and how it can be solved? can you give me the solution for that.??


Posted by
AJ
11 August 2004 @ 4pm

hi,

Not sure what the problem is, you might try posting your issue on the nokia discussion board:

http://discussion.forum.nokia.com/forum/forumdisplay.php?s=54741406724735a3ddbfa205bc4997ab&forumid=3

Hope that helps.

AJ


Posted by
joe
26 November 2004 @ 10am

Seems to work fine on my Nokia 6600.


Posted by
sandeep
28 February 2006 @ 7am

I m developing application in which i trying to post bytearray to server.but the server giving me response code as 403.
I am using series 40 nokia 6111 phone .

PLease anybody has information about it please tell me
Thank you
Sandeep


Posted by
Balaji
23 May 2007 @ 10pm

Hi,

Is it possible to saaj.jar in J2ME application. If it can how we need to implement the same.

Thanks and Reagrds,
Balaji.


Leave a Comment

my moblog ASP.NET Tracing