applet is downloaded on demand, without further interaction with the user. If the user clicks
a link that contains an applet, the applet will be automatically downloaded and run in the
browser. Applets are intended to be small programs. They are typically used to display data
provided by the server, handle user input, or provide simple functions, such as a loan
calculator, that execute locally, rather than on the server. In essence, the applet allows some
functionality to be moved from the server to the client.
The creation of the applet changed Internet programming because it expanded the
universe of objects that can move about freely in cyberspace. In general, there are two very
broad categories of objects that are transmitted between the server and the client: passive
information and dynamic, active programs. For example, when you read your e-mail, you are
viewing passive data. Even when you download a program, the program’s code is still only
passive data until you execute it. By contrast, the applet is a dynamic, self-executing
program. Such a program is an active agent on the client computer, yet it is initiated by the
server
As desirable as dynamic, networked programs are, they also present serious problems in
the areas of security and portability. Obviously, a program that downloads and executes
automatically on the client computer must be prevented from doing harm. It must also be
able to run in a variety of different environments and under different operating systems. As
you will see, Java solved these problems in an effective and elegant way. Let’s look a bit
more closely at each.
3. Security
As you are likely aware, every time that you download a “normal” program, you are taking
a risk because the code you are downloading might contain a virus, Trojan horse, or other
harmful code. At the core of the problem is the fact that malicious code can cause its
damage because it has gained unauthorized access to system resources. For example, a virus
program might gather private information, such as credit card numbers, bank account
balances, and passwords, by searching the contents of your computer’s local file system. In
order for Java to enable applets to be safely downloaded and executed on the client
computer, it was necessary to prevent an applet from launching such an attack.
Java achieved this protection by confining an applet to the Java execution environment
and not allowing it access to other parts of the computer. (You will see how this is
accomplished shortly.) The ability to download applets with confidence that no harm will be