Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 53
Registered: ‎06-24-2009
My Device: Not Specified
Accepted Solution

http connection ?

Hi all,

            I have tried below code but i am always getting ioexception but the same url works in browser.Plz let me know what is the probolem?

StreamConnection s = null; InputStream is = null; OutputStream os = null; String msg = null; int rc; try { s = (StreamConnection)Connector.open("http://wap.xxxxx.in:8080;deviceside=true"); HttpConnection c = (HttpConnection)s; // c.setRequestMethod(HttpConnection.GET); int status = c.getResponseCode(); if (status == HttpConnection.HTTP_OK) { is = s.openInputStream(); msg =""; DataInputStream dis = new DataInputStream(is); int ch; while ((ch = dis.read()) != -1) { msg = msg + (char) ch; //deBug(msg); } if(dis!=null){ dis.close(); dis=null; } } // deBug(msg); if (is != null){ is.close(); is = null; } if (s != null){ s.close(); s= null; } }catch(SecurityException se){ msg = "-2"; // deBug("Error in SecurityException: "+se.toString()); }catch(IOException ioe){ msg = "-1"; // deBug("Error in IOException: "+ioe.toString()); }catch(Exception e){ msg = "-1"; // deBug("Error in send: "+e.toString()); }

 


 

Developer
Posts: 293
Registered: ‎02-25-2009
My Device: Not Specified

Re: http connection ?

Check your apn settings are correct or not.

 

Check HttpDemo is working or not on your device.. if it works then try HttpDemo again by replacing the default URL with your URL in it.

 

 

if httpdemo is not working , then check your apn settings with operator.

 

 

~Amardeep

www.impetus.com

Developer
Posts: 53
Registered: ‎06-24-2009
My Device: Not Specified

Re: http connection ?

hi amardeepjaiman,

 thanks for your reply.i tried with httpdemo example too but the same exception i got it. but how could that url works in browser.(i am using airtel plan india) ?

Highlighted
Developer
Posts: 293
Registered: ‎02-25-2009
My Device: Not Specified

Re: http connection ?

Hi if you ar using airtel plan in india, check your tcp setting in advance options :  it shouyld be airtelgprs.com

 

or just use this line in code :

 

String url =  "http://wap.xxxxx.in:8080"+";deviceside=true;apn=airtelgprs.com";
s = (StreamConnection)Connector.open(url);

 

It should work now. try this

 

~Amardeep 

www.impetus.com