开发者

Passing binary data from Javascript into a Java applet via LiveConnect

开发者 https://www.devze.com 2023-01-27 00:35 出处:网络
I\'m working on an application with a javascript front end that can receive a bunch of octets from the server (for the time being I\'m using php\'s chr() to simulate some data).

I'm working on an application with a javascript front end that can receive a bunch of octets from the server (for the time being I'm using php's chr() to simulate some data).

Trying to pass the data from javascript into an applet to be manipulated is proving difficult. Since the data can have nulls mid-string, it looks like it gets terminated at the first null going in. It also looks like once 开发者_Python百科the binary data touches a javascript variable the encoding messes with some of the bytes (or maybe that's just a problem with how I'm displaying it)

Either way, what options do I have for taking a block of binary data, sent from a server and putting it into a Java applet to be manipulated. Is a conversion to base64 (or some other encoding) my only option if I want to maintain data integrity?

All this is new to me, so hopefully I got things across clearly.


Ah the bane of liveconnect.
Yes, you either need or use urlencode or base64 to get your data through.

Even when passing stuff from JavaScript to Flash (or back) you need to this, because the interface in between uses null terminated strings (which is just stupid, I know).


I think that architecture when your java script gets binary data and passes it to java applet is not optimal. Did you probably think to modify applet to make it to go directly to server and get the binary data? Without any java script?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号