2023年全國碩士研究生考試考研英語一試題真題(含答案詳解+作文范文)_第1頁
已閱讀1頁,還剩17頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、<p>  Java and the Internet</p><p>  If Java is, in fact, yet another computer programming language, you may question why it is so important and why it is being promoted as a revolutionary step in compu

2、ter programming. The answer isn’t immediately obvious if you’re coming from a traditional programming perspective. Although Java is very useful for solving traditional stand-alone programming problems, it is also importa

3、nt because it will solve programming problems on the World Wide Web.</p><p>  Client-side programming</p><p>  The Web’s initial server-browser design provided for interactive content, but the i

4、nteractivity was completely provided by the server. The server produced static pages for the client browser, which would simply interpret and display them. Basic HTML contains simple mechanisms for data gathering: text-e

5、ntry boxes, check boxes, radio boxes, lists and drop-down lists, as well as a button that can only be programmed to reset the data on the form or “submit” the data on the form back to the server. T</p><p>  

6、Many powerful Web sites today are built strictly on CGI, and you can in fact do nearly anything with it. However, Web sites built on CGI programs can rapidly become overly complicated to maintain, and there is also the p

7、roblem of response time. The response of a CGI program depends on how much data must be sent, as well as the load on both the server and the Internet. (On top of this, starting a CGI program tends to be slow.) The initia

8、l designers of the Web did not foresee how rapidly this band</p><p>  The solution is client-side programming. Most machines that run Web browsers are powerful engines capable of doing vast work, and with th

9、e original static HTML approach they are sitting there, just idly waiting for the server to dish up the next page. Client-side programming means that the Web browser is harnessed to do whatever work it can, and the resul

10、t for the user is a much speedier and more interactive experience at your Web site.</p><p>  The problem with discussions of client-side programming is that they aren’t very different from discussions of pro

11、gramming in general. The parameters are almost the same, but the platform is different: a Web browser is like a limited operating system. In the end, you must still program, and this accounts for the dizzying array of pr

12、oblems and solutions produced by client-side programming. The rest of this section provides an overview of the issues and approaches in client-side programming.</p><p>  2.Plug-ins</p><p>  One

13、of the most significant steps forward in client-side programming is the development of the plug-in. This is a way for a programmer to add new functionality to the browser by downloading a piece of code that plugs itself

14、into the appropriate spot in the browser. It tells the browser “from now on you can perform this new activity.” (You need to download the plug-in only once.) Some fast and powerful behavior is added to browsers via plug-

15、ins, but writing a plug-in is not a trivial task, and is</p><p>  3.Scripting languages</p><p>  Plug-ins resulted in an explosion of scripting languages. With a scripting language you embed the

16、 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. Scripting languages tend to be reaso

17、nably easy to understand and, because they are simply text that is part of an HTML page, they load very quickly as part of the single server hit required to procure that page. The tra</p><p>  This points ou

18、t that the scripting languages used inside Web browsers are really intended to solve specific types of problems, primarily the creation of richer and more interactive graphical user interfaces (GUIs). However, a scriptin

19、g 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 languages can allow easier and faster dev

20、elopment, you should probably consider a scrip</p><p>  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 Jav

21、a’s marketing momentum), VBScript (which looks like Visual Basic), and Tcl/Tk, which comes from the popular cross-platform GUI-building language. There are others out there, and no doubt more in development.</p>&

22、lt;p>  JavaScript is probably the most commonly supported. It comes built into both Netscape Navigator and the Microsoft Internet Explorer (IE). In addition, there are probably more JavaScript books available than the

23、re are for the other browser languages, and some tools automatically create pages using JavaScript. However, if you’re already fluent in Visual Basic or Tcl/Tk, you’ll be more productive using those scripting languages r

24、ather than learning a new one. (You’ll have your hands full dealing wi</p><p><b>  4.Java</b></p><p>  If a scripting language can solve 80 percent of the client-side programming pro

25、blems, 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 b

26、eing continually extended to provide language features and libraries that elegantly handle problems that are difficult in traditional programming languages, such as multithreading, database access, net</p><p&g

27、t;  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 activ

28、ated 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 ge

29、ts the latest version of the client software without fail and wi</p><p>  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 clie

30、nt. 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 Ja

31、va applet can comprise many modules and take multiple server “hits” (accesses) to download. (In Java 1.1 and higher this is minimized by Java archi</p><p><b>  5.ActiveX</b></p><p> 

32、 To some degree, the competitor to Java is Microsoft’s ActiveX, although it takes a completely different approach. ActiveX was originally a Windows-only solution, although it is now being developed via an independent con

33、sortium 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 Ac

34、tiveX and Netscape does so using a plug-in.) Thus, ActiveX do</p><p>  6.Security</p><p>  Automatically downloading and running programs across the Internet can sound like a virus-builder’s dre

35、am. 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

36、, compiled Java code, and ActiveX components. Some of these are benign; GIF files can’t do any harm, and scripting languages are generally limited in what they can do. Java was </p><p>  ActiveX is at the op

37、posite end of the spectrum. Programming with ActiveX is like programming Windows—you 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

38、 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 pr

39、oblem, but the speed of the Internet amp</p><p>  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 c

40、reator 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

41、will eliminate malicious mischief. If, however, a program has an unintentional destructive bug it will still cause problems</p><p>  The Java approach is to prevent these problems from occurring, via the san

42、dbox. 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

43、 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</p>&l

44、t;p>  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. The initial vision se

45、emed to be that eventually everyone would get online to do anything important, but that was soon seen to be impractical (although low-cost “Internet appliances” might someday satisfy the needs of a significant segment of

46、 users). The solution is the “signed applet” that uses public-key enc</p><p>  Digital signatures have missed an important issue, which is the speed that people move around on the Internet. If you download a

47、 buggy program and it does something untoward, how long will it be before you discover the damage? It could be days or even weeks. By then, how will you track down the program that’s done it? And what good will it do you

48、 at that point?</p><p>  7.Internet vs. intranet</p><p>  The Web is the most general solution to the client/server problem, so it makes sense that you can use the same technology to solve a sub

49、set of the problem, in particular the classic client/server problem within a company. With traditional client/server approaches you have the problem of multiple types of client computers, as well as the difficulty of ins

50、talling new client software, both of which are handily solved with Web browsers and client-side programming. When Web technology is used for an </p><p>  The security problem brings us to one of the division

51、s that seems to be automatically forming in the world of client-side programming. If your program is running on the Internet, you don’t know what platform it will be working under, and you want to be extra careful that y

52、ou don’t disseminate buggy code. You need something cross-platform and secure, like a scripting language or Java. </p><p>  If you’re running on an intranet, you might have a different set of constraints. It

53、’s not uncommon that your machines could all be Intel/Windows platforms. On an intranet, you’re responsible for the quality of your own code and can repair bugs when they’re discovered. In addition, you might already hav

54、e a body of legacy code that you’ve been using in a more traditional client/server approach, whereby you must physically install client programs every time you do an upgrade. The time wasted in ins</p><p>  

55、When faced with this bewildering array of solutions to the client-side programming problem, the best plan of attack is a cost-benefit analysis. Consider the constraints of your problem and what would be the shortest path

56、 to your solution. Since client-side programming is still programming, it’s always a good idea to take the fastest development approach for your particular situation. This is an aggressive stance to prepare for inevitabl

57、e encounters with the problems of program development.</p><p>  8.Server-side programming</p><p>  This whole discussion has ignored the issue of server-side programming. What happens when you m

58、ake a request of a server? Most of the time the request is simply “send me this file.” Your browser then interprets the file in some appropriate fashion: as an HTML page, a graphic image, a Java applet, a script program,

59、 etc. A more complicated request to a server generally involves a database transaction. A common scenario involves a request for a complex database search, which the server then formats</p><p>  9. separate

60、arena: applications</p><p>  Much of the brouhaha over Java has been over applets. Java is actually a general-purpose programming language that can solve any type of problem—at least in theory. And as pointe

61、d out previously, there might be more effective ways to solve most client/server problems. When you move out of the applet arena (and simultaneously release the restrictions, such as the one against writing to disk) you

62、enter the world of general-purpose applications that run standalone, without a Web browser, just like </p><p>  Be aware that this is a mixed blessing. You pay for the improvements through slower execution s

63、peed (although there is significant work going on in this area—JDK 1.3, in particular, introduces the so-called “hotspot” performance improvements). Like any language, Java has built-in limitations that might make it ina

64、ppropriate to solve certain types of programming problems. Java is a rapidly evolving language, however, and as each new release comes out it becomes more and more attractive for solvin</p><p><b>  Jav

65、a和因特網(wǎng)</b></p><p>  既然Java不過另一種類型的程序設(shè)計語言,大家可能會奇怪它為什么值得如此重視,為什么還有這么多的人認(rèn)為它是計算機(jī)程序設(shè)計的一個里程碑呢?如果您來自一個傳統(tǒng)的程序設(shè)計背景,那么答案在剛開始的時候并不是很明顯。Java除了可解決傳統(tǒng)的程序設(shè)計問題以外,還能解決World Wide Web(萬維網(wǎng))上的編程問題。</p><p><b&g

66、t;  1.客戶端編程</b></p><p>  Web最初采用的“服務(wù)器-瀏覽器”方案可提供交互式內(nèi)容,但這種交互能力完全由服務(wù)器提供,為服務(wù)器和因特網(wǎng)帶來了不小的負(fù)擔(dān)。服務(wù)器一般為客戶瀏覽器產(chǎn)生靜態(tài)網(wǎng)頁,由后者簡單地解釋并顯示出來?;綡TML語言提供了簡單的數(shù)據(jù)收集機(jī)制:文字輸入框、復(fù)選框、單選鈕、列表以及下拉列表等,另外還有一個按鈕,只能由程序規(guī)定重新設(shè)置表單中的數(shù)據(jù),以便回傳給服務(wù)器。用戶

67、提交的信息通過所有Web服務(wù)器均能支持的“通用網(wǎng)關(guān)接口”(CGI)回傳到服務(wù)器。包含在提交數(shù)據(jù)中的文字指示CGI該如何操作。最常見的行動是運行位于服務(wù)器的一個程序。那個程序一般保存在一個名為“cgi-bin”的目錄中(按下Web頁內(nèi)的一個按鈕時,請注意一下瀏覽器頂部的地址窗,經(jīng)常都能發(fā)現(xiàn)“cgi-bin”的字樣)。大多數(shù)語言都可用來編制這些程序,但其中最常見的是Perl。這是由于Perl是專為文字的處理及解釋而設(shè)計的,所以能在任何服務(wù)器

68、上安裝和使用,無論采用的處理器或操作系統(tǒng)是什么。</p><p><b>  2. 插件</b></p><p>  朝客戶端編程邁進(jìn)的時候,最重要的一個問題就是插件的設(shè)計。利用插件,程序員可以方便地為瀏覽器添加新功能,用戶只需下載一些代碼,把它們“插入”瀏覽器的適當(dāng)位置即可。這些代碼的作用是告訴瀏覽器“從現(xiàn)在開始,你可以進(jìn)行這些新活動了”(僅需下載這些插入一次)。有

69、些快速和功能強(qiáng)大的行為是通過插件添加到瀏覽器的。但插件的編寫并不是一件簡單的任務(wù)。在我們構(gòu)建一個特定的站點時,可能并不希望涉及這方面的工作。對客戶端程序設(shè)計來說,插件的價值在于它允許專業(yè)程序員設(shè)計出一種新的語言,并將那種語言添加到瀏覽器,同時不必經(jīng)過瀏覽器原創(chuàng)者的許可。由此可以看出,插件實際是瀏覽器的一個“后門”,允許創(chuàng)建新的客戶端程序設(shè)計語言(盡管并非所有語言都是作為插件實現(xiàn)的)。</p><p><b&

70、gt;  3. 腳本編制語言</b></p><p>  插件造成了腳本編制語言的爆炸性增長。通過這種腳本語言,可將用于自己客戶端程序的源碼直接插入HTML頁,而對那種語言進(jìn)行解釋的插件會在HTML頁顯示的時候自動激活。腳本語言一般都傾向于盡量簡化,易于理解。而且由于它們是從屬于HTML頁的一些簡單正文,所以只需向服務(wù)器發(fā)出對那個頁的一次請求,即可非??斓剌d入。缺點是我們的代碼全部暴露在人們面前。另一

71、方面,由于通常不用腳本編制語言做過分復(fù)雜的事情,所以這個問題暫且可以放在一邊。</p><p>  腳本語言真正面向的是特定類型問題的解決,其中主要涉及如何創(chuàng)建更豐富、更具有互動能力的圖形用戶界面(GUI)。然而,腳本語言也許能解決客戶端編程中80%的問題。你碰到的問題可能完全就在那80%里面。而且由于腳本編制語言的宗旨是盡可能地簡化與快速,所以在考慮其他更復(fù)雜的方案之前(如Java及ActiveX),首先應(yīng)想一

72、下腳本語言是否可行。</p><p>  目前討論得最多的腳本編制語言包括JavaScript(它與Java沒有任何關(guān)系;之所以叫那個名字,完全是一種市場策略)、VBScript(同Visual Basic很相似)以及Tcl/Tk(來源于流行的跨平臺GUI構(gòu)造語言)。當(dāng)然還有其他許多語言,也有許多正在開發(fā)中。</p><p>  JavaScript也許是日常用的,它得到的支持也最全面。無

73、論NetscapeNavigator,Microsoft Internet Explorer,還是Opera,目前都提供了對JavaScript的支持。除此以外,市面上講述JavaScript的書籍也要比講述其他語言的書多得多。有些工具還能利用JavaScript自動產(chǎn)生網(wǎng)頁。當(dāng)然,如果你已經(jīng)有Visual Basic或者Tcl/Tk的深厚功底,當(dāng)然用它們要簡單得多,起碼可以避免學(xué)習(xí)新語言的煩惱(解決Web方面的問題就已經(jīng)夠讓人頭痛了)

74、。</p><p><b>  4. Java</b></p><p>  如果說一種腳本編制語言能解決80%的客戶端程序設(shè)計問題,那么剩下的20%又該怎么辦呢?它們屬于一些高難度的問題嗎?目前最流行的方案就是Java。它不僅是一種功能強(qiáng)大、高度安全、可以跨平臺使用以及國際通用的程序設(shè)計語言,也是一種具有旺盛生命力的語言。對Java的擴(kuò)展是不斷進(jìn)行的,提供的語言特性和

75、庫能夠很好地解決傳統(tǒng)語言不能解決的問題,比如多線程操作、數(shù)據(jù)庫訪問、連網(wǎng)程序設(shè)計以及分布式計算等等。Java通過“程序片”(Applet)巧妙地解決了客戶端編程的問題。</p><p>  程序片(或“小應(yīng)用程序”)是一種非常小的程序,只能在Web瀏覽器中運行。作為Web頁的一部分,程序片代碼會自動下載回來(這和網(wǎng)頁中的圖片差不多)。激活程序片后,它會執(zhí)行一個程序。程序片的一個優(yōu)點體現(xiàn)在:通過程序片,一旦用戶需要

76、客戶軟件,軟件就可從服務(wù)器自動下載回來。它們能自動取得客戶軟件的最新版本,不會出錯,也沒有重新安裝的麻煩。由于Java的設(shè)計原理,程序員只需要創(chuàng)建程序的一個版本,那個程序能在幾乎所有計算機(jī)以及安裝了Java解釋器的瀏覽器中運行。由于Java是一種全功能的編程語言,所以在向服務(wù)器發(fā)出一個請求之前,我們能先在客戶端做完盡可能多的工作。例如,再也不必通過因特網(wǎng)傳送一個請求表單,再由服務(wù)器確定其中是否存在一個拼寫或者其他參數(shù)錯誤。大多數(shù)數(shù)據(jù)校驗

77、工作均可在客戶端完成,沒有必要坐在計算機(jī)前面焦急地等待服務(wù)器的響應(yīng)。這樣一來,不僅速度和響應(yīng)的靈敏度得到了極大的提高,對網(wǎng)絡(luò)和服務(wù)器造成的負(fù)擔(dān)也可以明顯減輕,這對保障因特網(wǎng)的暢通是至關(guān)重要的。 與腳本程序相比,Java程序片的另一個優(yōu)點是它采用編譯好的形式,所以客戶端看不到源碼。當(dāng)然在另一方面,反編譯Java程序片也并不是件</p><p>  5. ActiveX</p><p>

78、;  在某種程度上,Java的一個有力競爭對手應(yīng)該是微軟的ActiveX,盡管它采用的是完全不同的一套實現(xiàn)機(jī)制。ActiveX最早是一種純Windows的方案。經(jīng)過一家獨立的專業(yè)協(xié)會的努力,ActiveX現(xiàn)在已具備了跨平臺使用的能力。實際上,ActiveX的意思是“假如你的程序同它的工作環(huán)境正常連接,它就能進(jìn)入Web頁,并在支持ActiveX的瀏覽器中運行”(IE固化了對ActiveX的支持,而Netscape需要一個插件)。所以,Ac

79、tiveX并沒有限制我們使用一種特定的語言。比如,假設(shè)我們已經(jīng)是一名有經(jīng)驗的Windows程序員,能熟練地使用像C++、Visual Basic或者Borland Delphi那樣的語言,就能幾乎不加任何學(xué)習(xí)地創(chuàng)建出ActiveX組件。事實上,ActiveX是在我們的Web頁中使用“歷史遺留”代碼的最佳途徑。</p><p><b>  6. 安全</b></p><p&

80、gt;  自動下載和通過因特網(wǎng)運行程序聽起來就像是一個病毒制造者的夢想。在客戶端的編程中,ActiveX帶來了最讓人頭痛的安全問題。點擊一個Web站點的時候,可能會隨同HTML網(wǎng)頁傳回任何數(shù)量的東西:GIF文件、腳本代碼、編譯好的Java代碼以及ActiveX組件。有些是無害的;GIF文件不會對我們造成任何危害,而腳本編制語言通常在自己可做的事情上有著很大的限制。Java也設(shè)計成在一個安全“沙箱”里在它的程序片中運行,這樣可防止操作位于

81、沙箱以外的磁盤或者內(nèi)存區(qū)域。</p><p>  ActiveX是所有這些里面最讓人擔(dān)心的。用ActiveX編寫程序就像編制Windows應(yīng)用程序——可以做自己想做的任何事情。下載回一個ActiveX組件后,它完全可能對我們磁盤上的文件造成破壞。當(dāng)然,對那些下載回來并不限于在Web瀏覽器內(nèi)部運行的程序,它們同樣也可能破壞我們的系統(tǒng)。從BBS下載回來的病毒一直是個大問題,但因特網(wǎng)的速度使得這個問題變得更加復(fù)雜。

82、 目前解決的辦法是“數(shù)字簽名”,代碼會得到權(quán)威機(jī)構(gòu)的驗證,顯示出它的作者是誰。這一機(jī)制的基礎(chǔ)是認(rèn)為病毒之所以會傳播,是由于它的編制者匿名的緣故。所以假如去掉了匿名的因素,所有設(shè)計者都不得不為它們的行為負(fù)責(zé)。這似乎是一個很好的主意,因為它使程序顯得更加正規(guī)。但我對它能消除惡意因素持懷疑態(tài)度,因為假如一個程序便含有Bug,那么同樣會造成問題。</p><p>  Java通過“沙箱”來防止這些問題的發(fā)生。Java

83、解釋器內(nèi)嵌于我們本地的Web瀏覽器中,在程序片裝載時會檢查所有有嫌疑的指令。特別地,程序片根本沒有權(quán)力將文件寫進(jìn)磁盤,或者刪除文件(這是病毒最喜歡做的事情之一)。我們通常認(rèn)為程序片是安全的。而且由于安全對于營建一套可靠的客戶機(jī)/服務(wù)器系統(tǒng)至關(guān)重要,所以會給病毒留下漏洞的所有錯誤都能很快得到修復(fù)(瀏覽器軟件實際需要強(qiáng)行遵守這些安全規(guī)則;而有些瀏覽器則允許我們選擇不同的安全級別,防止對系統(tǒng)不同程度的訪問)。</p><p

84、>  大家或許會懷疑這種限制是否會妨礙我們將文件寫到本地磁盤。比如,我們有時需要構(gòu)建一個本地數(shù)據(jù)庫,或?qū)?shù)據(jù)保存下來,以便日后離線使用。最早的版本似乎每個人都能在線做任何敏感的事情,但這很快就變得非常不現(xiàn)實(盡管低價“互聯(lián)網(wǎng)工具”有一天可能會滿足大多數(shù)用戶的需要)。解決的方案是“簽了名的程序片”,它用公共密鑰加密算法驗證程序片確實來自它所聲稱的地方。當(dāng)然在通過驗證后,簽了名的一個程序片仍然可以開始清除你的磁盤。但從理論上說,既然現(xiàn)

85、在能夠找到創(chuàng)建人“算帳”,他們一般不會干這種蠢事。Java 1.1為數(shù)字簽名提供了一個框架,在必要時,可讓一個程序片“走”到沙箱的外面來。</p><p>  數(shù)字簽名遺漏了一個重要的問題,那就是人們在因特網(wǎng)上移動的速度。如下載回一個錯誤百出的程序,而它很不幸地真的干了某些蠢事,需要多久的時間才能發(fā)覺這一點呢?這也許是幾天,也可能幾周之后。發(fā)現(xiàn)了之后,又如何追蹤當(dāng)初肇事的程序呢(以及它當(dāng)時的責(zé)任有多大)?<

86、/p><p>  7. 因特網(wǎng)和內(nèi)聯(lián)網(wǎng)</p><p>  Web是解決客戶機(jī)/服務(wù)器問題的一種常用方案,所以最好能用相同的技術(shù)解決此類問題的一些“子集”,特別是公司內(nèi)部的傳統(tǒng)客戶機(jī)/服務(wù)器問題。對于傳統(tǒng)的客戶機(jī)/服務(wù)器模式,我們面臨的問題是擁有多種不同類型的客戶計算機(jī),而且很難安裝新的客戶軟件。但通過Web瀏覽器和客戶端編程,這兩類問題都可得到很好的解決。若一個信息網(wǎng)絡(luò)局限于一家特定的公司,

87、那么在將Web技術(shù)應(yīng)用于它之后,即可稱其為“內(nèi)聯(lián)網(wǎng)”(Intranet),以示與國際性的“因特網(wǎng)”(Internet)有別。內(nèi)聯(lián)網(wǎng)提供了比因特網(wǎng)更高的安全級別,因為可以物理性地控制對公司內(nèi)部服務(wù)器的使用。說到培訓(xùn),一般只要人們理解了瀏覽器的常規(guī)概念,就可以非常輕松地掌握網(wǎng)頁和程序片之間的差異,所以學(xué)習(xí)新型系統(tǒng)的開銷會大幅度減少。</p><p>  安全問題將我們引入客戶端編程領(lǐng)域一個似乎是自動形成的分支。若程序

88、是在因特網(wǎng)上運行,由于無從知曉它會在什么平臺上運行,所以編程時要特別留意,防范可能出現(xiàn)的編程錯誤。需作一些跨平臺處理,以及適當(dāng)?shù)陌踩婪?,比如采用某種腳本語言或者Java。</p><p>  但假如在內(nèi)聯(lián)網(wǎng)中運行,面臨的一些制約因素就會發(fā)生變化。全部機(jī)器均為Intel/Windows平臺是件很平常的事情。在內(nèi)聯(lián)網(wǎng)中,需要對自己代碼的質(zhì)量負(fù)責(zé)。而且一旦發(fā)現(xiàn)錯誤,就可以馬上改正。除此以外,可能已經(jīng)有了一些“歷史遺留

89、”的代碼,并用較傳統(tǒng)的客戶機(jī)/服務(wù)器方式使用那些代碼。但在進(jìn)行升級時,每次都要物理性地安裝一道客戶程序。浪費在升級安裝上的時間是轉(zhuǎn)移到瀏覽器的一項重要原因。使用了瀏覽器后,升級就變得易如反掌,而且整個過程是透明和自動進(jìn)行的。如果真的是牽涉到這樣的一個內(nèi)聯(lián)網(wǎng)中,最明智的方法是采用ActiveX,而非試圖采用一種新的語言來改寫程序代碼。</p><p>  面臨客戶端編程問題令人困惑的一系列解決方案時,最好的方案是先

90、做一次投資/回報分析。請總結(jié)出問題的全部制約因素,以及什么才是最快的方案。由于客戶端程序設(shè)計仍然要編程,所以無論如何都該針對自己的特定情況采取最好的開發(fā)途徑。這是準(zhǔn)備面對程序開發(fā)中一些不可避免的問題時,我們可以做出的最佳姿態(tài)。</p><p><b>  8服務(wù)器端編程</b></p><p>  我們的整個討論都忽略了服務(wù)器端編程的問題。如果向服務(wù)器發(fā)出一個請求,會

91、發(fā)生什么事情?大多數(shù)時候的請求都是很簡單的一個“把這個文件發(fā)給我”。瀏覽器隨后會按適當(dāng)?shù)男问浇忉屵@個文件:作為HTML頁、一幅圖、一個Java程序片、一個腳本程序等等。向服務(wù)器發(fā)出的較復(fù)雜的請求通常涉及到對一個數(shù)據(jù)庫進(jìn)行操作(事務(wù)處理)。其中最常見的就是發(fā)出一個數(shù)據(jù)庫檢索命令,得到結(jié)果后,服務(wù)器會把它格式化成HTML頁,并作為結(jié)果傳回來(當(dāng)然,假如客戶通過Java或者某種腳本語言具有了更高的智能,那么原始數(shù)據(jù)就能在客戶端發(fā)送和格式化;這

92、樣做速度可以更快,也能減輕服務(wù)器的負(fù)擔(dān))。另外,有時需要在數(shù)據(jù)庫中注冊自己的名字(比如加入一個組時),或者向服務(wù)器發(fā)出一份訂單,這就涉及到對那個數(shù)據(jù)庫的修改。這類服務(wù)器請求必須通過服務(wù)器端的一些代碼進(jìn)行,我們稱其為“服務(wù)器端的編程”。在傳統(tǒng)意義上,服務(wù)器端編程是用Perl和CGI腳本進(jìn)行的,但更復(fù)雜的系統(tǒng)已經(jīng)出現(xiàn)。其中包括基于Java的Web服務(wù)器,它允許我們用Java進(jìn)行所有服務(wù)器端編程,寫出的程序就叫做“小服務(wù)程序”(Servlet

93、)。</p><p>  9.一個獨立的領(lǐng)域:應(yīng)用程序</p><p>  與Java有關(guān)的大多數(shù)爭論都是與程序片有關(guān)的。Java實際是一種常規(guī)用途的程序設(shè)計語言,可解決任何類型的問題,至少理論上如此。而且正如前面指出的,可以用更有效的方式來解決大多數(shù)客戶機(jī)/服務(wù)器問題。如果將視線從程序片身上轉(zhuǎn)開(同時放寬一些限制,比如禁止寫盤等),就進(jìn)入了常規(guī)用途的應(yīng)用程序的廣闊領(lǐng)域。這種應(yīng)用程序可獨立

94、運行,毋需瀏覽器,就象普通的執(zhí)行程序那樣。在這兒,Java的特色并不僅僅反應(yīng)在它的移植能力,也反映在編程本身上。就像貫穿全書都會講到的那樣,Java提供了許多有用的特性,使我們能在較短的時間里創(chuàng)建出比用從前的程序設(shè)計語言更健壯的程序。</p><p>  但要注意任何東西都不是十全十美的,我們?yōu)榇艘惨冻鲆恍┐鷥r。其中最明顯的是執(zhí)行速度放慢了(盡管可對此進(jìn)行多方面的調(diào)整)。和任何語言一樣,Java本身也存在一些限

溫馨提示

  • 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. 眾賞文庫僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論