I was using the below code on most of the nokia phones when latelly my company decided to test our product with the new nokia n93
something very interesting occurred and that is that java write once run everywhere is not always as simple and less when things like
wat happenned are not documented any where......
The following code failed on the Nokia N93
String str = "HelloWorld";
byte bts = str.getBytes();
javax.microedition.io.HttpConnection con = (javax.microedition.io.HttpConnection)Connector.open(_URL, Connector.READ_WRITE, true);
//-- this is the source of the problem
con.setRequestProperty("IF-Modified-Since", "10 Nov 2000 17:29:12 GMT");
OutputStream os = con.openOutputStream();
//---- Here the code fails i.e. the phone takes about 1 minute to react and throws an IOException: -33
It took me 3 days sweating and testing to find out why? try google? nothing, try java.sun.com? nothing, try nokia developer website? nothing, try symbianos website? nothing.
I found out that the IF-Modified-Since value must be that of the current date and time at which the connection is openened or else the java running on nokia will elegantly through an IOException: -33 exception, this helps alot and saves you alot of time, because as you can see IOException: -33 tells you everything you need to know. I would like to congratulate the person who wrote this code and stab him a view times to show my gratitude.
To fix it I put in
java.util.Date d = new java.util.Date(System.currentTimeMillis());
Anybody doing connections out there and whant to use the nokia n93 although I suspect this may be something that will greep up with any new nokia, if you don't include the current date and time in the IF-Modified-Since property your code will fail and wont even write out to the output stream.