×

Discussion Board

Results 1 to 1 of 1

Hybrid View

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    166

    gettin exception when making httpconnection

    hi everybody

    I try to make midlet that connect to www using httpconnection .
    code work fine on j2me wireless toolkit emulator but don't work on actual handset 6600.

    is their problem with code or with handet my software version on 6600 is 3.42.1 16-10-03 nhl - 10

    i got error like javax.microedition.io.ConnectionNotFoundExeption:java.lang.ClassNotFoundExcepton

    here is the code


    recvt.setString("before conection");
    http = (HttpConnection)Connector.open(url,Connector.READ_WRITE);// i got error here
    recvt.setString(recvt.getString()+"after conection");
    http.setRequestMethod(HttpConnection.GET);
    http.setRequestProperty("CONTENT-TYPE","application/x-www-form-urlencoded");
    http.setRequestProperty("Accept","application/octet-stream");
    http.setRequestProperty("User-Agent","Profile/MIDP-2.0 Configuration/CLDC-1.0");
    http.setRequestProperty("Content-Language", "en-US");

    recvt.setString(recvt.getString()+"get conection");
    in = http.openInputStream();
    recvt.setString(recvt.getString()+"input stream");
    if(http.getResponseCode()==HttpConnection.HTTP_OK)
    {
    recvt.setString(recvt.getString()+"response ok");
    int length = (int)http.getLength();
    recvt.setString(recvt.getString()+"read length");

    if(length!=-1)
    { recvt.setString(recvt.getString()+"1");

    byte data[] = new byte[length];
    in.read(data);
    str = new String(data);
    recvt.setString(str);
    in.close();
    http.close();
    }
    else
    {
    recvt.setString(recvt.getString()+"2");

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    int ch;
    while((ch=in.read())!=-1)
    {
    out.write(ch);
    }
    str = new String(out.toByteArray());
    recvt.setString(str);
    out.close();
    in.close();
    http.close();
    }
    Last edited by kunal_the_one; 2004-07-08 at 07:01.

Posting Permissions

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