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
New Developer
iamtheboss1
Posts: 8
Registered: ‎08-22-2008
My Device: Not Specified

Re: HttpConnection how to?

Hello,

 

How do I "enable the network in simulator"?  I am using JDE4.1 and Simulator 7290.

Thanks.

 

Young

Please use plain text.
Developer
duksunkim
Posts: 141
Registered: ‎08-06-2008
My Device: Not Specified

Re: HttpConnection how to?

When you run simulator you will see the setup icon in first screen.

You just click that icon and follow the direction, and network setup part will be almost last.

 

Thanks.

Please use plain text.
New Developer
iamtheboss1
Posts: 8
Registered: ‎08-22-2008
My Device: Not Specified

Re: HttpConnection how to?

Duksunkim,

 

Thanks for the info.  Do you mean "Options" icon on blackberry simulator?  I went there and select "network", but I don't see how I can enable the network. 

 

Young

Please use plain text.
Developer
duksunkim
Posts: 141
Registered: ‎08-06-2008
My Device: Not Specified

Re: HttpConnection how to?

No, I mean on first the screen after you run the simulator, you will see 5 icons.

Setup Wizard

Messages

Call Log

Blackberry Messenger

Calendar

Applications

Select "Setup Wizard"

and you will see "Device Setup" and "Personalization" Directories, then Go to Application Permissions list under Personalization Directory.

 

 

 

 

 

Please use plain text.
New Developer
iamtheboss1
Posts: 8
Registered: ‎08-22-2008
My Device: Not Specified

Re: HttpConnection how to?

OK. I got the setup wizard from the 8120 simulator.

I tried the default access, but I still can not have the http demo successfully?  (gave the timeout error).  What did I do wrong?  Thanks much for the help.

 

Young

Please use plain text.
Developer
duksunkim
Posts: 141
Registered: ‎08-06-2008
My Device: Not Specified

Re: HttpConnection how to?

In my case, I select custom access and click next, and then I made all allow in the menu.

 

Please use plain text.
New Developer
iamtheboss1
Posts: 8
Registered: ‎08-22-2008
My Device: Not Specified

Re: HttpConnection how to?

Thanks Daksunkim for the info. BUt, unfortunately, I still can not make the httpdemo work.

 

Can anyone else help?  I have JDE4.3 and 8102 simulator. I am trying to run the httpdemo, but could not make it work.

I kept getting the "timeout error".   The web server that I am trying to access is actually the localhost, (I also tried other ones, but all with the same error). 

 

In the code below, it stuck at "httpConn.getResponseCode()".. and then error.  Really really appreciate if someone can help. 

 

Young

 

                StreamConnection s = null;
                try {
                    s = (StreamConnection)Connector.open(url);
                    HttpConnection httpConn = (HttpConnection)s;

                    int status = httpConn.getResponseCode();            /// here ======

 


                    if (status == HttpConnection.HTTP_OK)
                    {
                        //is this html?
                        String ctype = httpConn.getHeaderField(HEADER_CONTENTTYPE);
                        boolean htmlContent = (ctype != null && ctype.equals(CONTENTTYPE_TEXTHTML));

                        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;
                        }
                       
                        raw.insert(0, "bytes received]\n");
                        raw.insert(0, size);
                        raw.insert(0, '[');
                        String content = raw.toString();
                        if ( htmlContent )
                        {
                            content = raw.toString();
                        }
                        //The long operation is the parsing above,
                        // after the parsing is complete, shutdown the status thread
                        // before setting the text (since both threads modify the content
                        // pane, we want to make sure we don't have the status thread
                        // overwriting our data)
                        //stopStatusThread();
                        //updateContent(content);
                        input.close();
                    } else {
                        //stopStatusThread();
                        Dialog.alert("response code = " + status);
                    }
                    s.close();

                } catch (IOException e) {
                    System.err.println(e.toString());
                    Dialog.alert(e.toString());
                    //stopStatusThread();
                    //updateContent(e.toString());
                }

Please use plain text.
BlackBerry Development Advisor
MSohm
Posts: 14,685
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook

Re: HttpConnection how to?

Are you also running the MDS Simulator?  It is required to make socket or HTTP connections.

 

Also not that the BlackBerry does not allow connections to "localhost" or 127.0.0.1.  Instead, use your PC name or IP address.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
New Developer
iamtheboss1
Posts: 8
Registered: ‎08-22-2008
My Device: Not Specified

Re: HttpConnection how to?

Thank you much for the info.  "localhost" was the problem (as well as ";deviceside=true" which I forgot to add). 

Thanks again.

 

Young

Please use plain text.