燕山大学本科生毕业设计(翻译)
4.Java
If a scripting language can solve 80 percent of the client-side programming
problems, what about the other 20 percent—the “really hard stuff?” The most
popular solution today is Java. Not only is it a powerful programming language
built to be secure, cross-platform, and international, but Java is being
continually extended to provide language features and libraries that elegantly
handle problems that are difficult in traditional programming languages, such as
multithreading, database access, network programming, and distributed
computing. Java allows client-side programming via the applet.
An applet is a mini-program that will run only under a Web browser. The
applet is downloaded automatically as part of a Web page (just as, for example,
a graphic is automatically downloaded). When the applet is activated it executes
a program. This is part of its beauty—it provides you with a way to
automatically distribute the client software from the server at the time the user
needs the client software, and no sooner. The user gets the latest version of the
client software without fail and without difficult reinstallation. Because of the
way Java is designed, the programmer needs to create only a single program,
and that program automatically works with all computers that have browsers
with built-in Java interpreters. (This safely includes the vast majority of
machines.) Since Java is a full-fledged programming language, you can do as
much work as possible on the client before and after making requests of the
server. For example, you won’t need to send a request form across the Internet
to discover that you’ve gotten a date or some other parameter wrong, and your
client computer can quickly do the work of plotting data instead of waiting for
the server to make a plot and ship a graphic image back to you. Not only do you
get the immediate win of speed and responsiveness, but the general network
traffic and load on servers can be reduced, preventing the entire Internet from
slowing down.
One advantage a Java applet has over a scripted program is that it’s in
compiled form, so the source code isn’t available to the client. On the other
hand, a Java applet can be decompiled without too much trouble, but hiding
your code is often not an important issue. Two other factors can be important. As
you will see later in this book, a compiled Java applet can comprise many
modules and take multiple server “hits” (accesses) to download. (In Java 1.1 and
higher this is minimized by Java archives, called JAR files, that allow all the