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 source

9 thoughts on “J2ME Recipe Browser”

  1. 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.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.

  2. 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.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.??

  3. 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

  4. Hi,

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

    Thanks and Reagrds,

  5. hi frnds,
    i am doing my summer interns and i have to submit this project on j2me by 1st week of april2010 in the college…i have to create a plain web-browser application, which when installed in the mobile, should open the said website…which in turn should connect to the server…while connecting to the server it should provide the IMEI no. & various details about the handset.

    i am doing this project on netbeans6.8 and also on J2ME SDK.i had actually tried to code the browser and then add it to the form,but it shows some error…
    i tried by invoking mForm.append(browser);
    also can i add the browser component/control into the form through the design part in the netbeans….as it does in C#.NET..if it is..then how b’cos i tried to do so…but in vain…
    pls do help me…its very much urgent.
    thanking you in advance.

Leave a Reply

Your email address will not be published. Required fields are marked *