Hi ,
In my understanding each applets are independent entities . Is it possible to have inter applet communication ? . If so , how it could be achieved ?
Thanks J
Hi ,
In my understanding each applets are independent entities . Is it possible to have inter applet communication ? . If so , how it could be achieved ?
Thanks J
Two untrusted applets should not be able to communicate. The only exception is if they were launched from the same website. This would allow them to communicate using HTTP requests to that site or (as @Matthew states) by setting and reading cookies in the local cookie store.
Yes. You can use cookies, as detailed by this previous answer.
Yes. It is possible to achieve inter-applet communication if they are on the same page and originating from the same domain. You will have to name the applets in the page first using the attribute "name=value" like:
<applet code="FirstApplet.class" name="firstApplet" width=nn height=nn></applet>
<applet code="SecondApplet.class" name="secondApplet" width=nn height=nn></applet>
with above in place, in FirstApplet.java, use the following to access SecondApplet:
SecondApplet secondApplet =
(SecondApplet)getAppletContext().getApplet("secondApplet");
//invoke a method on secondApplet here
Similarly, you can access the FirstApplet in SecondApplet.java
Two applets in the same Applet Context can communicate easily enough. Unfortunately determining whether two applets are in the same context is not documented. Implementations may do surprising things, particularly when handling error or exhausted resource conditions.
Generally you should go back to the browser using LiveConnect to communicate, as Matthew Flaschen answer.
You can go further out and communicate to the originating server. Even if the applets are downloaded from different hosts, a communications path can be set up between the two origins. HTTP, or very much better HTTPS, should be a reliable way to communicate with the server.
There many more ways to communicate between two applet. I am not taking into the code. Just to mentions the ways, - Using Javascript - Static variables - Singleton Object - RMI