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: 51
Registered: ‎10-21-2008
My Device: Bold 9000
My Carrier: Dialog

Java HTTPConnection 406 - Not Acceptable

[ Edited ]



I am developing some blackberry application which use http connection. The program work fine on simulators. But when I install it to the device the http connection failed. Then I traced it by getResponseCode and getResponseMessage. Response Code = 406 Response Message = Null The program work fine with all simulators. The problem occur when I run this on the device. Please help me to sort out this issue.


Here is my coding.


import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import javax.microedition.io.*;
import java.io.InputStream;
class WebContentProvider {
    WebContentProvider() {    }
    public void GetContent(String UserName, String Password)
        mainwindow.lblMessage.setText("Please wait. System is validating your request");
            HttpConnection httpConnector = null;
            InputStream in = null;
            StringBuffer inBuffer = new StringBuffer();
            String response;
            int inChar;
            String URL="http://www.reservations.lk/test.php"  ;
            try {
            //Set the URL for this connection
            httpConnector = (HttpConnection)Connector.open(URL+";WapGatewayIP=;WapGatewayPort=9201;WapGatewayAPN=www.dialogwap.lk);
            //Set the HTTP request type
            //openInputStream initiates connection
            in = httpConnector.openInputStream();
            //read in all data until end of message
            while ((inChar = in.read()) != -1) {
                //append incoming chars to buffer
            response = inBuffer.toString();
            //close the inputStream
            //close the HTTP Connection
                mainwindow.lblMessage.setText("Invalid User Name or password. Please try again.");
                settings.SiteID = response;
                UiApplication.getUiApplication().pushScreen(new sites(response));
            } catch(Exception e){


Thank you.



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

Re: Java HTTPConnection 406 - Not Acceptable

for confirmation, did u appended the parameters ";deviceside=true" for directtcp....??


have you seen this thread??


Thanks and Regards,
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Java HTTPConnection 406 - Not Acceptable

You need to determine which part of the network is bouncing your request.  So trace the Web Server you are targeting and see if it actually sees your request.  I suspect note, I suspect your request is being bounced by the WAP Gateway.  I think you should try a Browser request from the same device, making sure you use the WAP Browser, and see if that gets through to your Web Server.  Assuming it does, then it would appear you need to set some http Headers so that your request can be passed through.  Sorry I've no idea what you WAP gateway will require, ask your carrier.


Alternatively you could try an another connection method, such as direct TCP.


See the network sticky Thread you have already been pointed to, most significantly look at both the Networking Videos for more information.


I think you got this code from the coderholics site, I suggest you review my comments about this code on that site.  Most significantly, the sample http code in the HttpConnection Javadocs does set http headers.

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

Re: Java HTTPConnection 406 - Not Acceptable

Your problem look like my problem before. So i think your method to connect is not correct. You can see this video Media Library .