×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    7

    Midlet running on emulator but not on the Nokia 6600 phone

    Hi,

    I have a problem with running the midlet on the nokia 6600. The midlet is working fine on Sun Wireless Toolkit and on carbide (using eclipse).

    The problem is that the midlet should read some results from a Servlet, in the emulator it´s working but on the Phone it prints NULL. Even after susing Carbide for series 60 and the series 60 SDK.

    Any suggestions?

    Thanks for your time and interest

  2. #2
    Registered User
    Join Date
    Apr 2006
    Posts
    7

    Re: Midlet running on emulator but not on the Nokia 6600 phone

    Hi,

    Is it that it should be a kind of configuration, or might be a deployement problem?

    Thanks

  3. #3
    Registered User
    Join Date
    Dec 2005
    Location
    Brazil
    Posts
    1,884

    Re: Midlet running on emulator but not on the Nokia 6600 phone

    Hi zizozine,

    Could you please elaborate on your problem. I assume you are using HttpConnection, right? What else?

    Be aware of the Nokia 6600 implementation. It has a lot of known issues and they are documented in the following resource:

    Known Issues In The Nokia 6600 MIDP 2.0 Implementation v1.7
    http://www.forum.nokia.com/info/sw.n..._7_en.pdf.html

    I hope it helps in any way...

    BR

    Juarez Junior

  4. #4
    Registered User
    Join Date
    Apr 2006
    Posts
    7

    Re: Midlet running on emulator but not on the Nokia 6600 phone

    Hi,

    I still can´t find what is the problem!?

    Can it be from the servlet? Dpes the servlet need to use a thread when it´s writing to the phone?

    Thanks,

  5. #5
    Registered User
    Join Date
    Dec 2005
    Location
    Brazil
    Posts
    1,884

    Re: Midlet running on emulator but not on the Nokia 6600 phone

    Hi zizozine,

    It'll help if you can provide more info, i mean, you stated that "it prints NULL", are you talking about the servlet? I assume you are...

    You can debug the response using a protocol analyzer/inspector like a HTTP tunnel, check the server logs and so on.

    No, Servlets are multithreaded and for each request one receives it is going to start a new thread for servicing this same request. What about your client code? Are you sure it is ok?

  6. #6
    Registered User
    Join Date
    Apr 2006
    Posts
    7

    Re: Midlet running on emulator but not on the Nokia 6600 phone

    Hi,

    Thanks juarezjunior for your reply

    Actually what i meant with "it prints NULL" is the following:

    The Midlet is running on the emulator fine, it prints some search results from aservlet in a TextBox. When i deployed the jar file to the phone, and tried to test it, in stead of printing results it just shows NULL in the TextBox. That what i meant with "It prints NULL".

    The following code is responsible for reading the results from the Servlet and printing it to the TextBox:
    /********************************************************/
    public boolean processResult(HttpConnection c, InputStream is) throws IOException{

    String result;
    int length = (int) c.getLength();

    //if the response is ok
    if (c.getResponseCode() == HttpConnection.HTTP_OK){

    if (length != -1){

    byte servletData[] = new byte[length];

    is.read(servletData);

    result = new String(servletData);

    }

    else{

    ByteArrayOutputStream bStrm = new ByteArrayOutputStream();

    int ch;

    while ((ch = is.read()) != -1)

    bStrm.write(ch);


    result = new String(bStrm.toByteArray());

    bStrm.close();

    }

    //Showing that the string result is empty
    if(result.length()<1)

    object.show(4);

    else{

    //initialize text box with the servlet result
    t2 = new TextBox("Trips available for entered informations:", result, 100000, TextField.UNEDITABLE);
    //call for method print of the main midlet(it will make the text box as the current display component)
    object.Print(t2, 2, "no");

    }

    return true;
    }

    else{

    //return false to indicate bad responce
    return false;

    }

    }
    /********************************************************/

    Thanks,

  7. #7
    Registered User
    Join Date
    Apr 2006
    Posts
    7

    Re: Midlet running on emulator but not on the Nokia 6600 phone

    Hi,

    This really urgent, please if anybody has any suggestions i will appreciate it.

    Thanks,

  8. #8
    Registered User
    Join Date
    Dec 2005
    Location
    Brazil
    Posts
    1,884

    Re: Midlet running on emulator but not on the Nokia 6600 phone

    Hi zizozine,

    Try using the code snippet below for reading the response and see what happens...

    in = conn.openInputStream();

    StringBuffer responseBuf;
    long length = conn.getLength();

    if (length > 0) {

    responseBuf = new StringBuffer((int) length);
    } else {
    responseBuf = new StringBuffer(); // 16 - tamanho default
    }

    int ch;

    while ((ch = in.read()) != -1) {
    responseBuf.append((char) ch);
    }
    responseStr = responseBuf.toString();

    where in is an InputStream, responseStr is a String and conn is a HttpConnection.

    I hope it helps!

    BR,

    Juarez Jr
    Last edited by juarezjunior; 2006-04-28 at 19:14.

  9. #9
    Registered User
    Join Date
    Apr 2006
    Posts
    7

    Re: Midlet running on emulator but not on the Nokia 6600 phone

    Hi juarezjunior,

    Thanks alot for your reply, i do really appreciate it

    I tried the code you suggested but the problem is still remaining!?

    I heard from alot of coleages that it´s hard to run alot of applications on Nokia phones, maybe that´s the problem!

    Thanks for all of you,

  10. #10
    Registered User
    Join Date
    May 2006
    Posts
    2

    Re: Midlet running on emulator but not on the Nokia 6600 phone

    We´ve detected a problem with the Nokia 6600. When an HTTP connection is used, a 0XFF byte received in the input stream is interpreted as "end of file" character and the conection is closed. This is a S.O. failure. We´ve tried with the last firmware version 5.53.0 for the 6600 and the problem remains.

    PLEASE NOKIA GUYS take note about this issue and correct it.

    We hope this help.

  11. #11
    Registered User
    Join Date
    May 2006
    Posts
    1

    Re: Midlet running on emulator but not on the Nokia 6600 phone

    I have had a similar problem for a number of days and have now got this working on an N70 where the emulator was fine, but on the phone it would not work.

    Solution for me was a combination of changing the responses from my web server to include content length in the header and then to also extend my http Connector request properties and well as extending my 'StreamFactory' to check for a length specified. The code for my StreamFactory is below :

    public class StreamFactory {

    public static ByteArrayOutputStream read(HttpConnection c, InputStream is) throws Exception, IOException
    {
    try
    {
    ByteArrayOutputStream byteStream = new ByteArrayOutputStream();

    int ch;

    if(c.getLength() != -1)
    {
    int length = (int) c.getLength();

    int actual = 0;
    int bytesread = 0;
    byte[] data = new byte[length];
    while ((bytesread != length) && (actual != -1))
    {
    actual = is.read(data, bytesread, length - bytesread);
    bytesread += actual;
    }
    byteStream.write(data);
    }
    else
    {
    while((ch = is.read()) != -1)
    byteStream.write(ch);
    }

    return byteStream;
    }
    catch(Exception e)
    {
    throw(e);
    }
    }

    }

    My use of this and how I now have my http request and StreamFactory returning the results I need is this:

    String deviceId = "deviceid=masonp";

    String registerURL = "http://my.web.server/mypage.php";

    c = (HttpConnection)Connector.open(registerURL);
    c.setRequestMethod(HttpConnection.POST);
    c.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
    c.setRequestProperty("Content-Length", Integer.toString(deviceId.length()));

    os = c.openOutputStream();
    os.write(deviceId.getBytes());

    is = c.openInputStream();

    // Retrieve the data from the input stream
    ByteArrayOutputStream byteStream = StreamFactory.read(c, is);

    The above example actual shows how I post information to a web page and successfully receive results back to an N70. Previous to deploying to an N70, I have had my code work on other phones without needing either the content length specified by the web server or the specific Connector request properties above detailed or the extended logic to check for a length when reading a response from a web server.

    Hope this helps....

  12. #12
    Registered User
    Join Date
    Jul 2006
    Posts
    3

    Re: Midlet running on emulator but not on the Nokia 6600 phone

    Solution I have:
    Normally when you browser through your mobile ,you connect through Access Point or Access Point Name(APN).these normally connect to WAP sites and you browse through them.
    When you want to access your own server (or servlets) from the j2me MIDlet suite you have to have the Access Point Setting to internet access.This you have to get the settings from the service provider of the mobile connection you are using. I am in India and using Hutch so I activated HUTCH_WWW ie "HUTCH ACCESS" Service.

    If this seeting is done your Httpconnection will work fine.
    Hope people who face similar problem will find this helpful.

    If problem persists then please contact me at vw_india@hotmail.com

    Vishwajeet Wadhwa

Similar Threads

  1. Replies: 2
    Last Post: 2008-04-03, 19:02
  2. Nokia 6600 phone memory / FExplorer
    By victorh81 in forum General Development Questions
    Replies: 2
    Last Post: 2005-02-08, 15:26
  3. A Midlet does not Start in phone 6600
    By gandalfin in forum Mobile Java General
    Replies: 4
    Last Post: 2005-01-04, 06:18
  4. MIDlet Deployment problems on Nokia 6600
    By lambertdavid in forum Mobile Java General
    Replies: 3
    Last Post: 2004-03-07, 11:26
  5. Running the midlet using Nokia 7650 emulator
    By sreevidhya in forum Mobile Java General
    Replies: 1
    Last Post: 2002-11-12, 06:02

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×