Application error in Nokia 6300

I am using this code to connect Servlet. Mobile application when trying to access the Internet.

The mobile phone displays the following message.

"Allow network access" yes "or" no. "If I press" no "for this message, the Nokia 6300" Application error "will display a warning and it will automatically close the application.

I have tried other Nokia mobile phones like N70 and N72. Mobile device will not display "Application Error".

Is Mobile a problem or coding issue?

Is there an efficient way to connect Servlet using http?

 public static InputStream getDataInputStream(String url, String request) 
 {
    HttpConnection httpConnectionObj = null;

    OutputStream dataOutputStreamObj = null;

    try {
        httpConnectionObj = (HttpConnection) Connector.open(url, Connector.READ_WRITE);

        httpConnectionObj.setRequestMethod(HttpConnection.POST);

        dataOutputStreamObj = httpConnectionObj.openOutputStream();

        dataOutputStreamObj.write(request.getBytes());

        dataOutputStreamObj.close();

        return httpConnectionObj.openInputStream();

    } catch (javax.microedition.io.ConnectionNotFoundException cnfe) {
      //Alert
    } catch (Exception ex) {
      //Alert
    } finally {
        try {
            if (httpConnectionObj != null) {
                httpConnectionObj.close();
                httpConnectionObj = null;
            }

        } catch (IOException ex) {
            ex.printStackTrace();
        }

    }
    return null;
}

      

+2


source to share


2 answers


There is no good way to extract java.lang.Throwable.printStackTrace()

on Nokia 6300 as it is a Series40 phone.

The issue with the permission dialog has nothing to do with your code. You need to be aware of the MIDP security model to fix this.

This phone has several security domains that are coded in its firmware by the phone manufacturer.

Each domain can have several options to restrict access to a sensitive API.

When you install a MIDlet, the phone decides which domain it belongs to based on who trusts the certificate with which you signed it. (can be unsigned, trusted third party, operator, manufacturer ...)



When you launch a MIDlet, each time it tries to use a restricted API, the appropriate option is applied. (You can always deny, ask the user every time, ask the user only once, always allow).

Different restricted APIs can have different parameters in the same domain.

Thus, there are several possible explanations for your problem:

  • You signed the MIDlet differently for the 6300 and the N70.
  • Security domains differ at 6300 and n70.
  • The ability to restrict HTTP connection is different from 6300 and N70.
  • Mobile network operator is different from 6300 and N70.
+2


source


I'm not sure if this helps, but try closing the output stream before the HttpConnection in a finally block:



    } finally {
        try {
            if (dataOutputStreamObj != null)
                dataOutputStreamObj.close();
            dataOutputStreamObj = null;

            if (httpConnectionObj != null)
                httpConnectionObj.close();
            httpConnectionObj = null;

        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

      

0


source







All Articles