Hello.
When I open an Http connection on the 7210 the first time in my application, I get the standard "Allow Web Access? (Yes/No)" question.
If I answer No, the Connector.getConnection() method throws a NullPointer exception which I cannot seem to catch.
The phone display reads "Application Error". Under details, "java.lang.NullPointerException".
On the 3650, I was able to handle the "No" response by catching the resulting IOException (code = -33 or such). But seemingly Series 40 phones can't handle this. I am especially concerned about this issue as I have seen this uncatchable NullPointer occasionally with other Http requests and don't fully understand it.
I am using standard HttpConnection code:
HttpConnection conn = (HttpConnection) Connector.open(request.url + request.requestStr);
// never reached during error condition.
if (conn == null) {
return null;
}
conn.setRequestMethod(HttpConnection.GET);
conn.setRequestProperty("Connection", "close");
InputStream is = conn.getInputStream();
.....
Has anyone else seen this or have any ideas on how to catch this exception or prevent it from happening?
Thanks
Tony

Reply With Quote

