Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Passing a byte array read from a file in an applet to a managed bean via javascript

KreetzSep 5 2013 — edited Sep 6 2013

Hi,

I have requirement to upload some pdf files from the local system to the application database as blob objects.

So far i have used an applet to read the files in the local file system and have read them into a byte array. Now when i try to send the byte array after encoding it to Base64 using Apache commons codec

String fileArr = Base64.encodeBase64String(<byte array>); it always returns null, i.e, fileArr is always null.And thus only null is sent to the managed bean via the javascript function.

Could you please help me with this or if there are some other ways to send a file from an applet.

I use the JSObject.call("functionName",params) method to call my javascript function from the applet which in turn calls the managed bean method using ADFCustomEvent and a server listener.

To add some more context to this situation i had previously tried using sun.misc.Base64Encoder to wrap the byte array to a String but using this, the javascript call from the applet using JSObject seems to stop dead in its track. However if i pass a normal "Hello World!" string or any other String for that matter it works just fine.

Also if i try to pass a InputStream of the file read at the applet, the Managed Bean receives it as a HashMap(no clue why).

Please Help !!

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 4 2013
Added on Sep 5 2013
5 comments
1,035 views