[ Pobierz całość w formacie PDF ]
.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 its in compiled form, so the source code isnt 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 required modules to be packaged together and compressed for a single download.) A scripted program will just be integrated into the Web page as part of its text (and will generally be smaller and reduce server hits).This could be important to the responsiveness of your Web site.Another factor is the all-important learning curve.Regardless of what youve heard, Java is not a trivial language to learn.If youre a Visual Basic programmer, moving to VBScript will be your fastest solution, and since it will probably solve most typical client/server problems you might be hard pressed to justify learning Java.If youre experienced with a scripting language you will certainly benefit from looking at JavaScript or VBScript before committing to Java, since they might fit your needs handily and youll be more productive sooner.ActiveXTo some degree, the competitor to Java is Microsofts ActiveX, although it takes a completely different approach.ActiveX was originally a Windows-only solution, although it is now being developed via an independent consortium to become cross-platform.Effectively, ActiveX says if your program connects to its environment just so, it can be dropped into a Web page and run under a browser that supports ActiveX. (IE directly supports ActiveX and Netscape does so using a plug-in.) Thus, ActiveX does not constrain you to a particular language.If, for example, youre already an experienced Windows programmer using a language such as C++, Visual Basic, or Borlands Delphi, you can create ActiveX components with almost no changes to your programming knowledge.ActiveX also provides a path for the use of legacy code in your Web pages.SecurityAutomatically downloading and running programs across the Internet can sound like a virus-builders dream.ActiveX especially brings up the thorny issue of security in client-side programming.If you click on a Web site, you might automatically download any number of things along with the HTML page: GIF files, script code, compiled Java code, and ActiveX components.Some of these are benign; GIF files cant do any harm, and scripting languages are generally limited in what they can do.Java was also designed to run its applets within a sandbox of safety, which prevents it from writing to disk or accessing memory outside the sandbox.ActiveX is at the opposite end of the spectrum.Programming with ActiveX is like programming Windowsyou can do anything you want.So if you click on a page that downloads an ActiveX component, that component might cause damage to the files on your disk.Of course, programs that you load onto your computer that are not restricted to running inside a Web browser can do the same thing.Viruses downloaded from Bulletin-Board Systems (BBSs) have long been a problem, but the speed of the Internet amplifies the difficulty.The solution seems to be digital signatures, whereby code is verified to show who the author is.This is based on the idea that a virus works because its creator can be anonymous, so if you remove the anonymity individuals will be forced to be responsible for their actions.This seems like a good plan because it allows programs to be much more functional, and I suspect it will eliminate malicious mischief.If, however, a program has an unintentional destructive bug it will still cause problems.The Java approach is to prevent these problems from occurring, via the sandbox.The Java interpreter that lives on your local Web browser examines the applet for any untoward instructions as the applet is being loaded.In particular, the applet cannot write files to disk or erase files (one of the mainstays of viruses).Applets are generally considered to be safe, and since this is essential for reliable client/server systems, any bugs in the Java language that allow viruses are rapidly repaired.(Its worth noting that the browser software actually enforces these security restrictions, and some browsers allow you to select different security levels to provide varying degrees of access to your system.)You might be skeptical of this rather draconian restriction against writing files to your local disk.For example, you may want to build a local database or save data for later use offline
[ Pobierz całość w formacie PDF ]