Previous | Next | Trail Map | Writing Applets | Table of Contents

Communicating with Other Programs

An applet can communicate with other programs in three ways: This lesson discusses and gives examples of each kind of applet communication.

Sending Messages to Other Applets on the Same Page

Using the AppletContext getApplet and getApplets methods, an applet can get the Applet objects for other applets running on the same page. Once an applet has another's Applet object, the applet can send messages to it.

Communicating with the Browser

Various Applet and AppletContext methods provide limited communication between the applet and the browser or applet viewer it runs in. The most interesting are probably the AppletContext showDocument methods, which let an applet tell its browser which URL to display.

Working with a Server-Side Application

Applets can use networking features just as any Java program can, with the restriction that all communication must be with the host that delivered the applet to its current host. This section presents an applet version of the example from Writing a Datagram Client and Server(in the Networking trail).

Also in this section is an example of how to use a server-side application to get around applet security restrictions. In the example, applets originating from the same host but running on different machines talk to each other using a server-side application as an intermediary.

Previous | Next | Trail Map | Writing Applets | Table of Contents