I am using this code to connect Servlet. Mobile application when try to access internet.
The following Message will appears in mobile.
"Allow network access?? yes or no ". If i click "no" for that message in Nokia 6300 "Application Error" Warning will appear and it will close the application automatically.
I tried other nokia mobiles like N70 and N72. Mobile will not show "Application Error".
Can any one helps me. is it Mobile problem or coding problem,
Is there any 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;
}