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


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.


Reply
Highlighted
Developer
Posts: 72
Registered: ‎06-29-2009
My Device: Not Specified

Writing files to a server and Character decoding failed

Hi All,

 

I am writing some data to the server which involves a JSON string as well as some images. I encode the JSON string using URLEncodedPostData with a UTF-8 character encoding and I am writing the bytes of the file to the same output stream. For some reason on the server side, Tomcat in this case, I see a bunch of Character decoding failed exceptions.

 

Does anyone know where I might be going wrong from this high level overview? Any suggestions as to an article or tutorial? All help much appreciated.

 

Kind Regards,

Schalk 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Writing files to a server and Character decoding failed

What type of encoding are you declaring in your HTTP header?

 

What type is accepted by the server? (Accept header)

 

Developer
Posts: 72
Registered: ‎06-29-2009
My Device: Not Specified

Re: Writing files to a server and Character decoding failed

Hi there,

 

I was using iso-..... and it seems the server wanted UTF-8. I changed this around and that seemed to solve the character encoding problem. The issues I have now is that everything seemingly get's written to the server (server responds with 200 and success reply) but, the images that I write to the output stream are never written to a file on the server side.

 

There are images created on the server but they are all of 0 bytes in length. Is there anything specifically needed when writing images from the BB to a server such? Thanks!

 

Kind Regards,

Schalk 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Writing files to a server and Character decoding failed

How are you encoding the image data?

 

What method are you using? POST?

 

Are you setting the data length in your POST?

 

 

 

Developer
Posts: 72
Registered: ‎06-29-2009
My Device: Not Specified

Re: Writing files to a server and Character decoding failed

Hi there,

 

I am reading the file from the file system/sd card using an implementation of the JSR75 spec which then returns the file as a byte array. I then write this array out to the OutputStream of the HTTPConnection. I have heard that some transport protocols required base64 encoding, is this something I need for this scenario or is there something else? Thank you for all of your help.

 

Kind Regards,

Schalk