Communication between applets

In my understanding, each applet is an independent object. Is it possible to have inter-network communication? If so, how can this be achieved?

Thanks J

+2


source to share


5 answers


Yes. It is possible to achieve interoperability between applets if they are on the same page and originate from the same domain. You will need to first name the applets on the page using the "name = value" attribute, for example:

<applet code="FirstApplet.class" name="firstApplet" width=nn height=nn></applet>
<applet code="SecondApplet.class" name="secondApplet" width=nn height=nn></applet>

      

with the above 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 FirstApplet in SecondApplet.java

+6


source


Yes. You can use cookies as described by this previous answer .



+1


source


The two untrusted applets shouldn't communicate. The only exception is if they were launched from the same website. This will allow them to communicate with HTTP requests on that site, or (like @Matthew states) by setting and reading cookies in the local cookie store.

0


source


Two applets in the same Applet Context can communicate fairly easily. Unfortunately, the definition that two applets are in the same context is not documented. Implementations can do amazing things, especially when handling errors or running out of resource conditions.

Typically, you have to go back to the browser using LiveConnect to respond, like Matthew Flashen's answer.

You can go ahead and contact the origin server. Even if applets are loaded from different hosts, it is possible to establish a communication path between the two sources. HTTP, or the very best HTTPS, should be a reliable way to communicate with the server.

0


source


There are many more ways to communicate between two applets. I do not accept the code. Just to mention the paths, - Using Javascript - Static Variables - Singleton Object - RMI

0


source







All Articles