JAVA外文文獻+翻譯_第1頁
JAVA外文文獻+翻譯_第2頁
JAVA外文文獻+翻譯_第3頁
已閱讀5頁,還剩8頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、JavaandtheIn ter netIf Java is, in fact, yet another computer programming Ianguage, you may question why it is so important and why it is being promoted as a revolutionary step in computer programming. The answer isn ' t immediately obvious if you coming'froen a traditional programming persp

2、ective. Although Java is very useful for solving traditional stand-alone programming problems, it is also important because it will solve program ming problems on the World Wide Web.1. Client-side programmingThe Web' snitial serve-browser desig n provided for in teractive content, but the in ter

3、activity was completely provided by the server. The server produced static pages for the clie nt browser, which would simply interpret and display them. Basic HTML contains simple mechanisms for data gathering: text-e ntry boxes, check boxes, radio boxes, lists and drop-dow n lists, as well as a but

4、t on that can only be programmed to reset the data on the form or “ submit the data on the form back to the server. This submissi on passes through the Com mon Gateway In terface (CGI) provided on all Web servers. The text within the submissi on tells CGI what to do with it. The most com mon actio n

5、 is to run a program located on the server in a directory that' s typicallybiralled (Ifou wafatgthe address window at the topof your browser whe n you push a butt on on a Web page, you can sometimes see -bin ” withi n acghe gobbledygook there.) These programs can be writte n in most Ian guages.

6、Perl is a com mon choice because it is desig ned for text mani pulati on and is in terpreted, so it can be in stalled on any server regardless of processor or operati ng system.Many powerful Web sites today are built strictly on CGI, and you can in fact do nearly anything with it. However, Web sites

7、 built on CGI programs can rapidly become overly complicated to maintain, and there is also the problem of resp onse time. The resp onse of a CGI program depe nds on how much data must be sent, as well as the load on both the server and the Intern et. (On top of this, start ing a CGI program tends t

8、o be slow.) The initial designers of the Web did not foresee how rapidly this bandwidth would be exhausted for the kinds of applicati ons people developed. For example, any sort of dyn amic graphi ng is n early impossible to perform with con siste ncy because a GIF file must be created and moved fro

9、m the server to the client for each version of the graph. And you' veio doubt had direct experienee with someth ing as simple as validat ing the data on an in put form. You press the submit butt on on a page; the data is shipped back to the server; the server starts a CGI program that discovers

10、an error, formats an HTML page informing you of the error, and the n sends the page back to you; you must the n back up a page and try again. Not only isthis slow, it ' s inelegant.The soluti on is clie nt-side program ming. Most mach ines that run Web browsers are powerful engines capable of do

11、ing vast work, and with the original static HTML approach they are sitting there, just idly wait ing for the server to dish up the n ext page. Clie nt-side program ming mea ns that the Web browser is harn essed to do whatever work it can, and the result for the user is a much speedier and more in te

12、ractive experie nee at your Web site.The problem with discussions of client-side programming is that they aren ' Very different from discussions of programming in general. The parameters are almost the same, but the platform is different: a Web browser is like a limited operati ng system .In the

13、 end, you must still program, and this acco unts for the dizzying array of problems and solutions produced by client-side programming. The rest of this secti on provides an overview of the issues and approaches in clie nt-side program ming.One of the most sig nifica nt steps forward in clie nt-side

14、program ming is the developme nt of the plug-i n. This is a way for a programmer to add new functionality to the browser by downloading a piece of code that plugs itself into the appropriate spot in the browser. It tells the browser “ fromnow on you can perform this new activity. (You need to downlo

15、ad the plug-in only once.) Some fast and powerful behavior is added to browsers via plug-ins, but writing a plug-in is not a trivial task, and isn' t somyou' d/vant to do as part of the process of building a particular site. The value of the plug-in for client-side programming is that it all

16、ows an expert programmer to develop a new language and add that Ian guage to a browser without the permissi on of the browser manu facturer. Thus, plug-i ns provide a“ backdoor ” that allows the creation of new client-side programming languages (although not all Ian guages are impleme nted as plug-i

17、 ns).lan guagesPlug-ins resulted in an explosion of scripting languages. With a scripting language you embed the source code for your client-side program directly into the HTML page, and the plug-in that interprets that language is automatically activated while the HTML page is being displayed. Scri

18、pting languages tend to be reas on ably easy to un dersta nd and, because they are simply text that is part of an HTML page, they load very quickly as part of the sin gle server hit required to procure that page. The trade-off is that your code is exposed for every one to see (and steal). Gen erally

19、, however, you aren ' doing amaz in gly sophisticated things with scripting languages so this is not too much of a hardship.This points out that the scripti ng lan guages used in side Web browsers are really inten ded to solve specific types of problems, primarily the creati on of richer and mor

20、e in teractive graphical user in terfaces (GUIs). However, a scripting language might solve 80 percent of the problems encountered in client-side programming. Your problems might very well fit completely within that 80 percent, and since scripting lan guages can allow easier and faster developme nt,

21、 you should probably con sider a scripti ng lan guage before look ing at a more invo Ived solutio n such as Java or ActiveX program ming.The most commonly discussed browser scripting languages are JavaScript (which has nothing to do with Java; it ' s named that way just to grab some of Java'

22、 s marketing momentum), VBScript (whi( like Visual Basic), and Tcl/Tk, which comes from the popular cross-platform GUI-building Ianguage. There are others out there, and no doubt more in developme nt.JavaScript is probably the most com monly supported. It comes built into both Netscape Navigator and

23、 the Microsoft Internet Explorer (IE). I n additi on, there are probably more JavaScript books available tha n there are for the other browser Ian guages, and some tools automatically create pagesus ing JavaScript. However, if you' reilready flue nt in Visual Basic or Tcl/Tk, you' lbe more p

24、roductive using those scripting Ianguages rather than learning a new one. (You have yoiih hands full dealing with the Web issues already.)If a scripti ng Ian guage can solve 80 perce nt of the clie nt-side program ming problems, what about the other 20 percen the “reallyhard stuff The most popular s

25、olution today is Java. Not only is it a powerful program ming Ian guage built to be secure, cross-platform, and intern ati on al, but Java is being continually extended to provide Ianguage features and libraries that elegantly handle problems that are difficult in traditional programming Ianguages,

26、such as multithreading, database access, network program ming, and distributed computi ng. Java allows clie nt-side program ming 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 gr

27、aphic is automatically dow nl oaded). 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 clie nt software from the server at the time the user n eeds the clie nt software, and no sooner. The user gets the latest v

28、ersion of the client software without fail and without difficult rein stallatio n. Because of the way Java is desig ned, the programmer n eeds to create only a sin gle program, and that program automatically works with all computers that have browsers with built-in Java interpreters. (This safely in

29、cludes the vast majority of machines.) Since Java is a full-fledged programming Ianguage, you can do as much work as possible on the client before and after making requests of theserver. For example, you won ' t need to send a request form across the Internet to discov that you ' ve gotten a

30、 date or some other parameter wrong, and your client computer can quickly do the work of plott ing data in stead of wait ing 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 resp on sive ness, but the gen eral n etwork traffic and

31、 load on servers can be reduced, preve nti ng the en tire Internet from slow ing dow n.One advantage a Java appet has over a scripted program is that it' s in compiled form, so the scode isn ' t available to the client. On the other hand, a Java applet can be decompiled without too much trou

32、ble, but hid ing your code is ofte n not an importa nt issue. Two other factors can be importa nt. 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 Javad higher this is minimized by Java archives, called

33、 JAR files, that allow all the required modules to be packaged together and compressed for a sin gle dow nl oad.) A scripted program will just be in tegrated into the Web page as part of its text (and will gen erally be smallerand reduce server hits). This could be important to the responsiveness of

34、 your Web site. Another factor is the all-important learning curve. Regardless of what you' ve heard, Java is not a trivial language tcIf you ' re a Visual Basic programmer, moving to VBScript will be your fastest solution, and since it Wil probably solve most typical clie nt/server problems

35、 you might be hard pressed to justify lear ning Java. If you' rexperie need with a script ing Ian guage you will certa inly ben efit from look ing at JavaScript or VBScript before committing to Java, since they might fit your needs handily and you' llbe more productive run its applets withiT

36、o some degree, the competitor to Java is Microsoft' s ActiveX, although it takes a completely(approach. ActiveX was originally a Windows-only solution, although it is now being developed via an in depe ndent con sortium to become crossplatform. Effectively, ActiveX says“ if your program conneto

37、its environment just so, it can be dropped into a Web page and run under a browser that supports ActiveX. ” (IE directlyjpports ActiveX and Netscape does so using a plug-in.) Thus, ActiveX does not constrain you to a particular Ianguage. If, for example, you' realready an experieneed Windows pro

38、grammer using a Ianguage such as C+, Visual Basic, or Borland' siDcedpli ActiveXcomp onents with almost no cha nges to your program ming kno wledge. ActiveX also provides a path for the use of legacy code in your Web pages.Automatically downloading and running programs across the Internet can so

39、und like a virus-builder s dream. ActiveX especially brings up the thorny issue of security in clie nt-side program min g. 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 ActieX components. So

40、me of these are benign; GIF files can do any harm, and scripti ng Ian guages are gen erally limited in what they can do. Java was also desig ned to run its applets within a“ sandbox ” of safety, which prevents it from writing to diskigmaeceoryoutside the san dbox.ActiveX is at the opposite end of th

41、e spectrum. Programming with ActiveX is like programming Windowsyou can do anything you want. So if you click on a page that downloads an ActiveX comp onent, that comp onent might cause damage to the files on your disk. Of course, programs that you load onto your computer that are not restricted to

42、running in side a Web browser can do the same thing. Viruses dow nl oaded from Bulleti n-Board Systems (BBSs) have long bee n a problem, but the speed of the Internet amplifies the difficulty.The soluti on seems to be“ digital sig natures, ” whereby code is verified to show who the authois based on

43、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 fun cti on al, and I suspect it will elimi nate malicious mischief.I

44、f, however, a program has an unintentional destructive bug it will still cause problems.The Java approach is to preve nt these problems from occurri ng, via the san dbox. The Java in terpreter that lives on your local Web browser examines the applet for any untoward instructions as the applet is bei

45、ng loaded. In particular, the applet cannot write files to disk or erase files (one of the main stays of viruses). Applets are gen erally con sidered to be safe, and since this is esse ntial for reliable clie nt/server systems, any bugs in the Java Ianguage that allow virues are rapidly repaired. (I

46、t' s worth noting thatbrowser software actually enforces these security restrictions, and some browsers allow you to select differe nt security levels to provide vary ing degrees of access to your system.)You might be skeptical of this rather draconian restriction against writing files to your l

47、ocal disk. For example, you may want to build a local databaseor save data for later use offline. The initial vision seemed to be that eve ntually every one would get on li ne to do anything importa nt, but that was soon see n to be impractical (although low-cost “Internetappliances might someday sa

48、tisfy the needs of a sig nifica nt segme nt of users). The soluti on is the“ sig ned app-ktey gn ctyptiune® pubfcthat an applet does in deed come from where it claims it does. A sig ned applet can still trash your disk, but the theory is that since you can now hold the applet creator accountabl

49、e they won' t do vprovides a framework for digital sig natures so that you will eve ntually be able to allow an applet to step outside the san dbox if n ecessary.Digital sig natures have missed an importa nt issue, which is the speed that people move around on the Internet. If you download a bug

50、gy program and it does something untoward, how long will it be before you discover the damage It could be days or eve n weeks. By the n, how will you track dow n the program that ' s done it And what good will it do you at that pointvs. intranetThe Web is the most general solution to the client/

51、server problem, so it makes sense that you can use the same tech no logy to solve a subset of the problem, in particular the classic clie nt/server problem with in a company. With traditional client/server approachesyou have the problem of multiple types of client computers, as well as the difficult

52、y of installing new client software, both of which are handily solved with Web browsers and clie nt-side program ming. When Web tech no logy is used for an in formati on network that is restricted to a particular company, it is referred to as an intranet. Intranets provide much greater security than

53、 the Internet, since you can physically control accessto the servers within your company. In terms of training, it seems that once people understand the general conce pf a browser it ' s much easier for them to deal with differences in the way pages and applets look, so the learning curve for ne

54、w kinds of systems seems to be reduced.The security problem brings us to one of the divisions that seems to be automatically forming in the world of client-side programming. If your program is running on the Internet, you don' know what platform it will be working under, and you want to be extra

55、 careful that you don' t disseiYou n eed someth ing cross-platform and secure, like a scripti ng Ian guage or Java.If you ' re running on an intranet, you might have a different set of constraints. It'your machines could all be Intel/Windows platforms. On an intranet, you' re respons

56、ible for tyour own code and can repair bugs when they' re discovered. In addition, you might already have a b(of legacy code that you' vbeen using in a more traditional client/server approach, whereby you must physically in stall clie nt programs every time you do an upgrade. The time wasted

57、 in in stalli ng upgrades is the most compelli ng reas on to move to browsers, because upgrades are inv isible and automatic. If you are invo Ived in such an intran et, the most sen sible approach to take is the shortest path that allows you to use your existi ng code base, rather tha n trying to re

58、code your programs in a new Ian guage.When faced with this bewilderi ng array of soluti ons to the clie nt-side program ming problem, the best plan of attack is a cost-benefit analysis. Consider the constraints of your problem and what would be the shortest path to your soluti on. Since clie ntside

59、program ming is still program min g, it' s always a gooto take the fastest development approach for your particular situation. This is an aggressive stance to prepare for in evitable encoun ters with the problems of program developme gram mingThis whole discussion has ignored the issue of

60、server-side programming. What happenswhen you make a request of a server Most of the time the request is simply“ send me this file. ”in terprets the file in some appropriate fashi on: as an HTML page, a graphic image, a Java applet, a script program, etc. A more complicated request to a server gen erally invo Ives a

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論