Tuesday, October 16, 2007

Transferring information between Java applets

I stumbled upon a rather lengthy article at TechRepublic about a workaround for one of the Java applet security limitations, which does not allow any information to be passed between Java applets originating from different servers. The article talks about transferring files, but there is no reason not to generalize it to the transfer of any kind of information.

Their solution is to write what they call a "middleman" - an application that should reside on a web server and route the traffic between its applet and the "middleman" application running on the server of the other applet, which in its turn should forward the information to the receiving applet.

Well... it's surely an interesting exercise, but... guys, this is stupid!

The following trivial hack using Javascript allows you to do the same, i.e. pass information between two Java applets originating from different servers, in a fraction of an effort needed to implement the hack from TechRepublic article. This is actually very simple - the above Java applets are not allowed to communicate with each other, but they both can communicate with the Javascript!

There are a couple of ways to call Java code from Javascript, but the simplest is "java.package.class.staticMethod()". So all you have to do is to call the relevant methods of both classes from Javascript and pass the information from one to another.

Java applet security limitations, Sun Java security specifications

Labels: , ,


Post a Comment

Subscribe to Post Comments [Atom]

<< Home