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
Developer
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified
Accepted Solution

HTTP GET Request always returning with "?" at the beginning

Hello everyone,

 

I've been experimenting with displaying HTML content in a BrowserField (5.0) two different ways:

 

  1. Using browserField.requestContent(url);
  2. Retrieving the HTML from "url" using an HTTP GET request, and then displaying the retrieved HTML with:
browserField.displayContent(response, http://localhost);

 

I would like to use method #2 because I want to be able to cache the HTML source into persistent storage. However, for some reason, when I use method #2, the HTML returned by the HTTP Response contains a "?" at the very beginning of the response/html:

 

? <html><body>Founded in 2008, ...

 

I've concluded that the problem is not with my .html page.  The question mark seems to be introduced during the HTTP Request/Response.  However when I use the same #2 method for a different URL, say google.com, the source is returned without a question mark.

 

Any ideas?

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

Re: HTTP GET Request always returning with "?" at the beginning

I'm just going to be brief here, as I think you might be able to work this out for yourself and so save me time....

 

I suspect you have a BOM - Byte Order mark, which is used by some Web sites,  Search wikipedia for more detailed information. 

 

Anyway, you really don't want to convert the html you get from UTF-8 and then give the String to the Browser Field, because this will not be converted back to UTF-8 correctly.  So I suspect that you can just receive the html input in byte form, including the BOM, and pass it straight through to the BrowserField.

 

See this Thread for more:

http://supportforums.blackberry.com/t5/Java-Development/Displaying-UTF-8-string-problem-in-browserFi...

Developer
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified

Re: HTTP GET Request always returning with "?" at the beginning

Hi peter_strange,

 

That was dead on, thank you.  I was pulling my hair out on that one for awhile.  Changing the code to not convert to UTF-8 removed the BOM.

 

Thanks again.