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

This entry was posted in J2ME, Mobile Devices, XML. Bookmark the permalink.

9 Responses to J2ME Recipe Browser

  1. Matt Liotta says:

    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?

  2. AJ says:

    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?

  3. wendong says:

    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.

  4. Pranav says:

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

  5. AJ says:

    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

  6. joe says:

    Seems to work fine on my Nokia 6600.

  7. sandeep says:

    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

  8. Balaji says:

    Hi,

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

    Thanks and Reagrds,
    Balaji.

  9. ashish pai says:

    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 *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>