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

Posts: 264
Registered: ‎06-04-2009
My Device: Not Specified

HttpConnection basic question



I have a basic question regarding httpconnection it may sound sill sorry for that


in the httpconnection part in the below code the httpconnection object will poen the connection and will get the response. How does this connector work . I have a webservice which refresh the data in my application its xml based. I want to know if I can use the same webservice to ping the server . I dont want to get the response part just want to ping the server. Is it possible or in each connection the response object contains the whole response data and http headers . I really dont want the user to incur any cost for this operation other than pining the server. 

             c = (HttpConnection)Connector.open(url);

             // Getting the response code will open the connection,
             // send the request, and read the HTTP response headers.
             // The headers are stored until requested.
             rc = c.getResponseCode();
             if (rc != HttpConnection.HTTP_OK) {
                 throw new IOException("HTTP response code: " + rc);

             is = c.openInputStream();
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: HttpConnection basic question

If you just want to check that access to the server is available, then use a separate URL that sends minimal data in response.  Otherwise you will get sent all the data.


Does that answer the question?