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.

New Developer
Posts: 3
Registered: ‎09-10-2009
My Device: Not Specified

Custom BrowserFieldConfig for Cookies?

Hi there,


there is a known issue SDR336322 which describes a problem with setting cookies in a net.rim.device.api.browser.field2.BrowserField

(Details here: http://docs.blackberry.com/en/developers/deliverables/8546/Known_issues_491056_11.jsp)


I expierence this problem when setting two cookies on my test-site - only one cookies gets set per request, so I would have to load the page twice to have both cookies set.

The provided workaround assumes to "not use the default net.rim.device.api.browser.field2.BrowserFieldConfig"

So what should I do instead? Subclassing BrowserFieldConfig of course doesn't solve the problem.


Is there any clue when this will be fixed? Any (official/not official) information about when to expect the release of 5.0?


Thanks in advance,


New Contributor
Posts: 9
Registered: ‎01-07-2010
My Device: Not Specified

Re: Custom BrowserFieldConfig for Cookies?



Did you managed to find any solution on that?





New Contributor
Posts: 9
Registered: ‎01-07-2010
My Device: Not Specified

Re: Custom BrowserFieldConfig for Cookies?

Hello Blackberians


i finally managed to find a solution by my own, those are the steps that i followed


(1) The cookie (http header actually) that my internal browser should set was like


Set-Cookie: JSESSIONID=FA3687789B2AE5D3A0E89B1DE7EA0173; Path=/mypath; Secure; HttpOnly

BROWSER REQUEST (i should send)

Cookie: JSESSIONID=FA3687789B2AE5D3A0E89B1DE7EA0173


(2) i set a global var in my main class like

private String myCookie = "";


(3)Set Protocol Controller (there i can set cookies for the requests)

         _bf2 = new BrowserField(_bfConfig);

        _controller = new ProtocolController(_bf2) {
            public void handleNavigationRequest(final BrowserFieldRequest request) throws Exception {
                try {
                    HttpHeaders myHttpHeaders = request.getHeaders();
                    for(int mm=0; mm<myHttpHeaders.size(); ++mm){
                        String mykey   = myHttpHeaders.getPropertyKey(mm);
                        String myvalue = myHttpHeaders.getPropertyValue(mm);
                    if(myCookie != null && !myCookie.equalsIgnoreCase("")){
                        System.out.println("------>added the "+"Cookie"+"="+myCookie);
                    BrowserFieldRequest mybfr = new BrowserFieldRequest(request.getURL(), request.getPostData(), myHttpHeaders);
                } catch (Throwable e) { ; }
        _bfConfig.setProperty(BrowserFieldConfig.CONTROLLER, _controller);


(4) create a class Mybdebug that extends BrowserFieldDebugger like

    class Mybdebug extends BrowserFieldDebugger {
        public void notifyHttpTraffic(HttpConnection connection, Hashtable requestHeaders){
                for(int j=0; j<10; ++j){
                    String myHeader = connection.getHeaderFieldKey(j);
                    String myValue  = connection.getHeaderField(j);
                    System.out.println("------>bdebug "+myHeader+"="+myValue);
                        myCookie = myValue;
                        if(myCookie == null && !myCookie.equalsIgnoreCase("")){
                            System.out.println("------>MY COOKIE is NULL!!! myCookie="+myCookie);
                            if(myCookie.indexOf("; Path")>0){
                                myCookie = myCookie.substring(0,myCookie.indexOf("; Path"));
            }catch(Exception e){
                System.out.println("------>bdebug(1) Exception");


(5) Add the bdebug object to your  BrowserField like

        Mybdebug bdebug = new Mybdebug();



Hope that this helps



Thank you



Posts: 13
Registered: ‎06-18-2009
My Device: Not Specified

Re: Custom BrowserFieldConfig for Cookies?



its been seen that attaching a debugger to the production application is not a good idea as it slows down your application very much, and can even lead to hanged application.


I am also handling the cookies by self, by two means i.e.


1 by implementing the Cookie manager and setting it in to the BrowserFieldConfig object.

2 by adding those cookie back in to the connection in the above same implemented class.

3 as mentioned above in the response step (3).

4 a fourth place could be which need to be verified if the browserfield calls the cookie manager set cookie method on the cookie recieved in the HTTPS redircetion (AUTH cookie). i wasnt able to confirm that but the above steps works for me.



Please let me know if it doesnt work.



New Developer
Posts: 40
Registered: ‎12-04-2009
My Device: Storm 9530

Re: Custom BrowserFieldConfig for Cookies?



I am integrated SAML 2.0 SSO using browserfield and I have used implementation which you have posted. But once I try to login and that will redirect to another URL that time I am getting "java.io.EOFException". Do you have any idea can I resolved this exception?