×

Discussion Board

Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25
  1. #16
    Registered User
    Join Date
    May 2009
    Posts
    4

    Re: Http connection using J2ME URL working on emulator but not on the Real Device

    Hi jitu_goldie,

    I have similar issue.
    In my case, Everything is working fine on emulator. However when I run it in Nokia 5800, it can connect to my web server, but can't get response. I'm using PHP on my server side. The code is:

    String response = "";
    try {
    HttpConnection conn = (HttpConnection) Connector.open(this.url);
    conn.setRequestMethod(HttpConnection.POST);
    byte[] data = {};
    String parameter = "strRequest=test";
    data = parameter.getBytes();

    conn.setRequestProperty("Content-Length", Integer.toString(data.length));
    conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    OutputStream send = conn.openOutputStream();
    send.write(data);
    send.close();

    InputStream input = conn.openInputStream();
    int ch;
    ByteArrayOutputStream bstr = new ByteArrayOutputStream();
    while( (ch = input.read()) != -1 ) {
    bstr.write(ch);
    }
    response = new String(bstr.toByteArray());

    conn.close();
    } catch (IOException ex) {
    System.out.println("Exception Occured:" + ex.getMessage());
    }
    Last edited by honeybin; 2009-05-27 at 03:20. Reason: wrong code

  2. #17
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: Http connection using J2ME URL working on emulator but not on the Real Device

    Might be the problem is on server side.
    thanks,
    jitu_goldie..

    KEEP TRYING..

  3. #18
    Registered User
    Join Date
    May 2009
    Posts
    4

    Re: Http connection using J2ME URL working on emulator but not on the Real Device

    Hello jitu_goldie,

    Thank you for your reply.
    And I have tested, server side is ok. And I found it can't connect to server side, when I tested it again.

    Thank you
    Bin

  4. #19
    Registered User
    Join Date
    May 2009
    Posts
    4

    Re: Http connection using J2ME URL working on emulator but not on the Real Device

    Hi,
    I'm still stuck in httpconnection. Please help me out. Now the issue is that it working fine on emulator but still now working on my Nokia 5800. I just wrote a very simple httpconnection program. it just connect to http://www.google.com.au. It is working on emulator. but on my Nokia 5800 mobile phone, the program just stop at " int resCode = conn.getResponseCode();" and didn't print any exception. Any ideas please?
    try{
    conn = (HttpConnection) Connector.open(this.url);
    conn.setRequestMethod(HttpConnection.GET);
    int resCode = conn.getResponseCode();
    if (resCode != HttpConnection.HTTP_OK) {
    //print out 'failed'
    } else {
    //print out 'success'
    }
    } catch (IOException ex) {
    System.out.println("Exception Occured:" + ex.getMessage());
    }

    Thanks a lot

  5. #20
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: Http connection using J2ME URL working on emulator but not on the Real Device

    Please do one thing. Just take a FORM and print all the results over there. Add a command at ur application to show this Form and add a command to Form to get back to ur main process. Even print exception at form. This is the only way to debug on device AFAIK.
    Try this and check whats the exception if any and whats the response code.
    thanks,
    jitu_goldie..

    KEEP TRYING..

  6. #21
    Registered User
    Join Date
    Apr 2009
    Posts
    16

    Re: Http connection using J2ME URL working on emulator but not on the Real Device

    Is there any special character in r URL?

  7. #22
    Registered User
    Join Date
    May 2009
    Posts
    4

    Re: Http connection using J2ME URL working on emulator but not on the Real Device

    Thanks guys for your help.
    The problem has been fixed. It was the problem with my mobile networking setting.

  8. #23
    Regular Contributor
    Join Date
    Mar 2009
    Posts
    89

    Re: Http connection using J2ME URL working on emulator but not on the Real Device

    Hi Honey,

    what are the network settings required.

  9. #24
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: Http connection using J2ME URL working on emulator but not on the Real Device

    Quote Originally Posted by kpvrlakshmi View Post
    Hi Honey,

    what are the network settings required.
    Just remove ur installed settings and ask ur service provider for GPRS settings.
    thanks,
    jitu_goldie..

    KEEP TRYING..

  10. #25
    Registered User
    Join Date
    Apr 2009
    Posts
    16

    Re: Http connection using J2ME URL working on emulator but not on the Real Device

    Thanks Friends,

    Now problem has been resolved. Because '&' used as a seperator in URL, so I replaced it by _^_. Problem was occurred by '^' character. So i replaced it by %5e, Now it is working fine.

Similar Threads

  1. [moved] how to call a web service from Http connection in j2me?
    By mindIt in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2009-02-10, 09:17
  2. Http Connection and dialing a call not working on phone
    By electracool in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2007-12-14, 05:19
  3. working in emulator but not real mobile device
    By mmc18 in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2006-03-27, 17:56
  4. HTTP Connection issue
    By akhilss in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2005-09-12, 19:31
  5. HTTP connection on 6310i, 7650, 9210 and in sony-ericsson p800
    By mika1982 in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2003-07-24, 16:44

Posting Permissions

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