このコードを使用してサーブレットを接続しています。インターネットにアクセスしようとしたときのモバイル アプリケーション。
次のメッセージがモバイルに表示されます。
「ネットワーク アクセスを許可しますか?? はいまたはいいえ」. Nokia 6300 でそのメッセージに対して [いいえ] をクリックすると、[アプリケーション エラー] という警告が表示され、アプリケーションが自動的に閉じられます。
N70 や N72 などの他の nokia モバイルを試してみました。モバイルでは「アプリケーション エラー」は表示されません。
モバイルの問題ですか、それともコーディングの問題ですか?
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;
}