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
Posts: 20
Registered: ‎06-13-2010
My Device: Curve
My Carrier: T-Mobile

Get HTML Content of a webpage

I'm attempting to send a tiny bit of data to a website, the website accepts the data like so,

 

http://website.com?data=x

 

so nothing complex, the returned HTML will also be the result so "OK" or "Exception....."

 

Whast the best way to do this using BlackBerry.

Developer
Posts: 73
Registered: ‎10-23-2009
My Device: Not Specified

Re: Get HTML Content of a webpage

There's no quick-and-dirty way that I am aware of.  The method I've always used is openConnection(url) .  The most thorough source of information on Blackberry connectivity I know of is this post:

http://supportforums.blackberry.com/t5/Java-Development/Connecting-your-BlackBerry-http-and-socket-c...

 

Good luck!

~NN

Developer
Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified

Re: Get HTML Content of a webpage

use HTTP POST method.

 

the following link will be useful.

http://vasudevkamath.blogspot.com/2009/09/posting-data-via-http-from-blackberry.html

Thanks and Regards,
PraveenGoparaju.
New Developer
Posts: 20
Registered: ‎06-13-2010
My Device: Curve
My Carrier: T-Mobile

Re: Get HTML Content of a webpage

Thanks for the reply, there is no mention (at a quick gtrl+f) of a function openConnection()

 

Can you explain more?

Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: Get HTML Content of a webpage

It's actually Connector.open( url [, mode [, timeout ] ] ). The Connector class has the basic documentation. Peter's sticky post and the RIM videos on network transport are also extremely helpful.




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
New Developer
Posts: 20
Registered: ‎06-13-2010
My Device: Curve
My Carrier: T-Mobile

Re: Get HTML Content of a webpage

[ Edited ]

When using the connector class i get the following error.

 

"Tunnel Failed"

 

Anyone have any ideas what this meens?

 

Please note this is not in the simulator but on an actual blackberry

And the code,

 

try {
                                                Connector.open("http://www.website.net/track?userid=1&x="+class.getX());
                                                txtBOX.setText(txtBOX.getText() + " ++" + "Sent");
                                        } catch (IOException e) {
                                                // TODO Auto-generated catch block
                                                txtBOX.setText(txtBOX.getText() + " ++" + e.getMessage());
                                        }

Developer
Posts: 19,631
Registered: ‎07-14-2008
My Device: Not Specified

Re: Get HTML Content of a webpage

There are two problems with your code.

 

1) It would appear that you need to re-read the documentation other posts have pointed you at.   You should have realized form this information

a) that the Simulator and the real device are completely different in this regard, and

b) you need to determine and set an appropriate connection suffix

 

I suggest you review the sticky Thread again, and especially the Rim supplied 'Required Reading' that is suggested. 

 

2) You are running this code on the Event Thread.  You need to do networking in a separate (background) Thread. 

 

You will find that the httpdemo sample that should have been included with your development tool will help you with running the networking in a separate Thread.