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

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

Posts: 144
Registered: ‎12-20-2008
My Device: Not Specified

HTTP Get Stream connection

I want to retrieve the content of a php page thet returns a string it keeps failing wht is wrong here is the code



                    System.err.println("Abrir conexion");
                    s = (StreamConnection)Connector.open(_theUrl, Connector.READ, true);
                    HttpConnection httpConn = (HttpConnection)s;


enters up to here then fails i need to put the correct property

                   // httpConn.setRequestProperty("User-Agent", "BlackBerry/0.1");
                      int status = httpConn.getResponseCode();
                    if (status == HttpConnection.HTTP_OK)
                        java.io.InputStream input = s.openInputStream();
                        byte[] data = new byte[256];
                        int len = 0;
                        int size = 0;
                        StringBuffer raw = new StringBuffer();
                        while ( -1 != (len = input.read(data)) )
                            raw.append(new String(data, 0, len));
                            size += len;
                        java.util.Vector messages = parseMessage(raw.toString());
                catch (java.io.IOException e)

BlackBerry Development Advisor
Posts: 15,889
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: HTTP Get Stream connection

Please refer to the httpdemo included with the BlackBerry JDE for an example of making an HTTP connection.


What happens when the connection fails?  Is an exception thrown?  If so, what is it?  What BlackBerry model and handheld software version are you testing with?  You can find this under Options, About on the BlackBerry handheld.  What route is your connecting being made over?


What Is - Different ways to make an HTTP or socket connection
Article Number: DB-00396


Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.