How To Communicate Between Java Applets

By Angsuman Chakraborty, Gaea News Network
Monday, October 22, 2007

Communication between Java applets has been an interesting topic from the early days of Java. There are several esoteric ways to communicate like using Javascript as a bridge. However we will look into the simplest and most reliable method of intra-applet communication.

Simple solution to applet communication problem
Use a class with static getters and setters method(s) to pass data around. Since the applets are loaded in the same JVM, the static methods can be used to share any kind of data between the applets.

Another more complex solution is to use the database to communicate data between the applets. This may be useful if the applets are on different machines or different JVM’s as in two application server / tomcat instances.

Discussion

sphemy
September 10, 2008: 9:01 am

with the new jre (update 10) is it possible to run different applets in another classloader => statics won’t work anymore

October 22, 2007: 11:12 pm

As far as I know both IE & Firefox loads the applets using the same classloader.

With different classloaders, yes.

October 22, 2007: 4:12 pm

hi there,

what happens if the JVM applet engine uses different classloaders to load the classes ? there will be 2 different instances of the classes, right ?

BR,
~A

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :