On the BrowserField2 (BlackBerry OS 5 and OS 6) the BrowserField has method to load the content from the String HTML raw.

this is the code for the previous version of BlackBerry OS, how to invoke the browser with the raw HTML.

The mechanism for using the BlackBerry Browser to invoke the browser with raw HTML content is shown in the sample code below. The key aspect of the code is the section where you pass in the following string to the browser at the start of the data sequence:


* RawHTMLBrowserSample.java
* © Research In Motion Limited, 2007
* Confidential and proprietary.

import java.io.*;
import javax.microedition.io.*;
import net.rim.blackberry.api.browser.*;
import net.rim.device.api.io.*;
import net.rim.device.api.system.*;
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.util.*;

* A simple example of how to invoke the BlackBerry Browser using
* raw HTML data.
public class RawHTMLBrowserSample extends UiApplication
    public static void main( String[] args )
        RawHTMLBrowserSample sample = new RawHTMLBrowserSample();

    * Create the splash screen and start off the networking
    * thread that will eventually invoke the browser.
    public RawHTMLBrowserSample()
        MainScreen splashScreen = new MainScreen();
        splashScreen.add( new RichTextField( "Please Wait..." ));
        pushScreen( splashScreen );
        MyThread thread = new MyThread();
    private static class MyThread extends Thread
        public void run()
            try {
            // Open the connection and the input stream. Select your own URL.
            HttpConnection connection = (HttpConnection)Connector.open( "http://www.blackberry.com:80" );
            InputStream input = connection.openInputStream();
            DataBuffer buffer = new DataBuffer();
            byte[] temp = new byte[ 1024 ];
            // Read in the web page to the DataBuffer.
            for( ;; ) {
                int bytesRead = input.read( temp );
                if( bytesRead == -1 ) {
                buffer.write( temp, 0, bytesRead );
            // Create an output stream that will be used by the Base64 code.
            ByteArrayOutputStream output = new ByteArrayOutputStream();
            Base64OutputStream boutput = new Base64OutputStream( output );
            // Write out the special sequence which indicates to the browser
            // that it should treat this as HTML data in base64 format.
            output.write( "data:text/html;base64,".getBytes() );
            boutput.write( buffer.getArray() );
            output.close(); // Invoke the browser with the encoded HTML content.
            BrowserSession bSession = Browser.getDefaultSession();
            bSession.displayPage( output.toString() );
        } catch( IOException e ) {
            System.out.println( "IOException: " + e );

The browser uses the sequence to base64 decode the string following the comma and displays it in the browser. When displaying the page, images and other items do not appear because the browser cannot fetch them.

This article applies to BlackBerry® Device Software 4.2 and later.

[1] http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/796557/800332/800440/How_To_-_Invoke_the_browser_with_raw_HTML.html?nodeid=1313878&vernum=0?CPID=EMC-DM2007M-37