midlet error when using httpconnection in netbeans

Discussion in 'Java' started by Orson, Mar 8, 2005.

  1. Orson

    Orson Guest

    hi,
    i'm quite new in writing midlets, so maybe answer to my question is
    obviuos.
    my application needs to use http connection but when i try to run it
    the whole emulator (DefaultColorPhone) stops and a message is
    displayed that application "wants to send and recieve data using the
    network. This will use airtime and may result in charges. Is it ok to
    use airtime?". there are two options yes/no but application isn't
    responding.
    the same situation occurs when i try to run sample application which
    use any type of connection.

    if anyone had this kind of problem please respond.
    yours sincerely
    orson
    Orson, Mar 8, 2005
    #1
    1. Advertising

  2. Orson wrote:
    > i'm quite new in writing midlets, so maybe answer to my question is
    > obviuos.
    > my application needs to use http connection but when i try to run it
    > the whole emulator (DefaultColorPhone) stops and a message is
    > displayed that application "wants to send and recieve data using the
    > network. This will use airtime and may result in charges. Is it ok to
    > use airtime?". there are two options yes/no but application isn't
    > responding.
    > the same situation occurs when i try to run sample application which
    > use any type of connection.


    Can you show us the code you're using to create the HTTP connection? It
    sounds like you're blocking the main thread by opening the connection on
    that thread rather than spawning a new thread to handle the connection...

    --
    Darryl L. Pierce <>
    Visit my homepage: http://mcpierce.multiply.com
    "By doubting we come to inquiry, through inquiry truth." - Peter Abelard
    Darryl Pierce, Mar 13, 2005
    #2
    1. Advertising

  3. Orson

    ritu

    Joined:
    Sep 5, 2007
    Messages:
    3
    http connection error



    i want to transfer file from computer to mobile. getting same type of error : do u want to use airtime ? nothing happens irrespective of reply and the midlet hangs..
    i tried using localhost.. this time the midlet doesn't hang but instead of reading and displaying file contents, it shows this : 'Error ..'

    please reply if anyone has some solution for me

    one more thing i need to know is what are the prerequisites for installing eclipse 3.0?
    ritu, Sep 5, 2007
    #3
  4. Orson

    ashok_alex

    Joined:
    Aug 26, 2008
    Messages:
    3
    hello im Ashok ,Im facing this same problem when i try to call servlet from midlet by using
    (HttpConnection) open(url);
    ashok_alex, Aug 26, 2008
    #4
  5. Orson

    ashok_alex

    Joined:
    Aug 26, 2008
    Messages:
    3
    below i pasted the code , in that im facing 'Is it ok to use Airtime?' msg on my midlet screen. plz tell me clearly and i using new thread to establish the connection. eventhough im facing the same problem. explain me clearly
    ashok_alex, Aug 26, 2008
    #5
  6. Orson

    ashok_alex

    Joined:
    Aug 26, 2008
    Messages:
    3
    below i pasted the code , in that im facing 'Is it ok to use Airtime?' msg on my midlet screen. plz tell me clearly and i using new thread to establish the connection. eventhough im facing the same problem. explain me clearly

    code:

    private void callServlet()
    {
    //throw new UnsupportedOperationException("Not yet implemented");
    System.out.println("from call servlet b4 thread start");
    //thread.start();

    new Thread(this).start();


    }




    public void run()
    {

    System.out.println("from run()");

    HttpConnection http = null;
    InputStream iStrm = null;
    boolean ret = false;


    String source_stn="MS";
    String dest_stn="PER";



    String url = "http://localhost:8080/WebUTSApplication/MobileServlet"+"?"+"src_stn=" + source_stn+"&"+"des_stn=" + dest_stn;
    //String url = "http://localhost:8080/WebUTSApplication/MobileServlet";
    // String baseurl = "http://localhost:8080/WebUTSApplication/MobileServlet";
    System.out.println("URL ="+url);


    try {

    System.out.println("with in try block");
    http = (HttpConnection) Connector.open(url);
    System.out.println("after open url");
    //http = open(url);
    http.setRequestMethod(HttpConnection.POST);

    //http.setRequestMethod(HttpConnection.GET);



    } catch (IOException ex) {
    ex.printStackTrace();
    }
    }
    ashok_alex, Aug 26, 2008
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ravi Ambros Wallau
    Replies:
    0
    Views:
    1,206
    Ravi Ambros Wallau
    Oct 25, 2004
  2. Kenneth P. Turvey

    Midlet distribution as .prc in NetBeans

    Kenneth P. Turvey, Nov 21, 2004, in forum: Java
    Replies:
    1
    Views:
    982
    JScoobyCed
    Nov 22, 2004
  3. Replies:
    0
    Views:
    595
  4. guyzdancin
    Replies:
    0
    Views:
    567
    guyzdancin
    Jan 11, 2006
  5. guyzdancin
    Replies:
    2
    Views:
    532
    Andrea Desole
    Jan 13, 2006
Loading...

Share This Page