Core Java(TM) 2, Volume I--Fundamentals (7th Edition) (Core Series) (Core Series)
The idea here is simple: users will download Java bytecodes from the Internet and run them on their own machines. Java programs that work on web pages are called applets. To use an applet, you need a Java-enabled web browser, which will execute the bytecodes for you. Because Sun is licensing the Java source code and insisting that there be no changes in the language and basic library structure, a Java applet should run on any browser that is advertised as Java-enabled. Unfortunately, reality has been different. Various versions of Netscape and Internet Explorer run different versions of Java, some of which are seriously outdated. This sorry situation made it increasingly difficult to develop applets that take advantage of the most current Java version. To remedy this problem, Sun has developed the Java Plug-in, a tool that makes the newest Java runtime environment available to both Netscape and Internet Explorer (see Chapter 10). When the user downloads an applet, it works much like embedding an image in a web page. The applet becomes a part of the page, and the text flows around the space used for the applet. The point is, the image is alive. It reacts to user commands, changes its appearance, and sends data between the computer presenting the applet and the computer serving it. Figure 1-1 shows a good example of a dynamic web page an applet to view molecules that carries out sophisticated calculations. By using the mouse, you can rotate and zoom each molecule to better understand its structure. This kind of direct manipulation is not achievable with static web pages, but applets make it possible. (You can find this applet at http://jmol.sourceforge.net.) Figure 1-1. The Jmol applet
Applets can be used to add buttons and input fields to a web page. But downloading those applets over a dialup connection is slow, and you can do much of the same with Dynamic HTML, HTML forms, and a scripting language such as JavaScript. And, of course, early applets were used for animation: the familiar spinning globes, dancing cartoon characters, nervous text, and so on. But animated GIFs can do much of the same. Thus, applets are necessary only for rich interactions, not for general web design. As a result of browser incompatibilities and the inconvenience of downloading applet code through slow connections, applets on Internet web pages have not become a huge success. The situation is entirely different on intranets. There are typically no bandwidth problems, so the download time for applets is no issue. And in an intranet, it is possible to control which browser is being used or to use the Java Plug-in consistently. Employees can't misplace or misconfigure programs that are delivered through the Web with each use, and the system administrator never needs to walk around and upgrade code on client machines. Many corporations have rolled out programs such as inventory checking, vacation planning, travel reimbursement, and so on, as applets that use the browser as the delivery platform. At the time of this writing, the pendulum has swung back from client-focused programs to server-side programming. In particular, application servers can use the monitoring capabilities of the Java virtual machine to perform automatic load balancing, database connection pooling, object synchronization, safe shutdown and restart, and other services that are needed for scalable server applications but are notoriously difficult to implement correctly. Thus, application programmers can buy rather than build these sophisticated mechanisms. This increases programmer productivity programmers focus on their core competency, the business logic of their programs, and not on tweaking server performance. |