版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、<p> 畢業(yè)設(shè)計(jì)外文資料翻譯</p><p><b> ?。ㄗg文)</b></p><p> 題目名稱: Java and the Internet </p><p> 學(xué) 院: 計(jì)算機(jī)科學(xué)技術(shù) </p><p> 專業(yè)年級(jí): 計(jì)算
2、機(jī)科學(xué)與技術(shù)(師)08 級(jí) </p><p> 學(xué)生姓名: aaa </p><p> 班級(jí)學(xué)號(hào): a班a號(hào) </p><p> 指導(dǎo)教師: aaa </p><p> 二○一一 年 五 月 十三 日&l
3、t;/p><p> 譯文題目: Java和因特網(wǎng) </p><p> 原文題目: Java and the Internet </p><p> 原文出處: http://wenku.baidu.com/view.html </p><p>
4、; 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 computer prog
5、ramming. 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 important becau
6、se 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 interacti
7、vity 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-entry box
8、es, 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> Many pow
9、erful 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 problem o
10、f 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 initial design
11、ers 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 the origin
12、al 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 result for th
13、e 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 programming
14、 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 problems a
15、nd 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 of the m
16、ost 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 into the
17、 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-ins, but
18、 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 source
19、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 reasonably ea
20、sy 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 out that t
21、he 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 scripting langua
22、ge 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 development
23、, 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 Java’s mark
24、eting 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><p>
25、 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 there are f
26、or 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 rather th
27、an 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 problems, w
28、hat 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 con
29、tinually 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> An a
30、pplet 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
31、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 l
32、atest 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 client. On t
33、he 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 apple
34、t 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> To some
35、 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 consortium
36、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 an
37、d 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 dream. Acti
38、veX 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, compil
39、ed 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 opposite e
40、nd 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 on your
41、 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, b
42、ut 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 creator c
43、an 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 eli
44、minate 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 sandbox. Th
45、e 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 mai
46、nstays 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><p>
47、 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 seemed to
48、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 users).
49、 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 buggy p
50、rogram 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 at that
51、 point?</p><p> 7.Internet vs. intranet</p><p> referred to as an intranet. Intranets provide much greater security than the Internet, since you can p The Web is the most general solution to t
52、he client/server problem, so it makes sense that you can use the same technology to solve a subset of the problem, in particular the classic client/server problem within a company. With traditional client/server approach
53、es you have the problem of multiple types of client computers, as well as the difficulty of installing new client software, both of whic</p><p> The security problem brings us to one of the divisions that s
54、eems 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 you don’t
55、 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’s not u
56、ncommon 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 have a body
57、 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> When fac
58、ed 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 to your
59、 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 inevitable encoun
60、ters 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 make a re
61、quest 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, etc. A
62、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 arena: a
63、pplications</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 pointed out pr
64、eviously, 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 enter th
65、e 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 speed (al
66、though 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 inappropria
67、te 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> Java和因特網(wǎng)<
68、;/b></p><p> 既然Java不過(guò)另一種類型的程序設(shè)計(jì)語(yǔ)言,大家可能會(huì)奇怪它為什么值得如此重視,為什么還有這么多的人認(rèn)為它是計(jì)算機(jī)程序設(shè)計(jì)的一個(gè)里程碑呢?如果您來(lái)自一個(gè)傳統(tǒng)的程序設(shè)計(jì)背景,那么答案在剛開(kāi)始的時(shí)候并不是很明顯。Java除了可解決傳統(tǒng)的程序設(shè)計(jì)問(wèn)題以外,還能解決World Wide Web(萬(wàn)維網(wǎng))上的編程問(wèn)題。</p><p><b> 1.客戶
69、端編程</b></p><p> Web最初采用的“服務(wù)器-瀏覽器”方案可提供交互式內(nèi)容,但這種交互能力完全由服務(wù)器提供,為服務(wù)器和因特網(wǎng)帶來(lái)了不小的負(fù)擔(dān)。服務(wù)器一般為客戶瀏覽器產(chǎn)生靜態(tài)網(wǎng)頁(yè),由后者簡(jiǎn)單地解釋并顯示出來(lái)?;綡TML語(yǔ)言提供了簡(jiǎn)單的數(shù)據(jù)收集機(jī)制:文字輸入框、復(fù)選框、單選鈕、列表以及下拉列表等,另外還有一個(gè)按鈕,只能由程序規(guī)定重新設(shè)置表單中的數(shù)據(jù),以便回傳給服務(wù)器。用戶提交的信息通過(guò)所
70、有Web服務(wù)器均能支持的“通用網(wǎng)關(guān)接口”(CGI)回傳到服務(wù)器。包含在提交數(shù)據(jù)中的文字指示CGI該如何操作。最常見(jiàn)的行動(dòng)是運(yùn)行位于服務(wù)器的一個(gè)程序。那個(gè)程序一般保存在一個(gè)名為“cgi-bin”的目錄中(按下Web頁(yè)內(nèi)的一個(gè)按鈕時(shí),請(qǐng)注意一下瀏覽器頂部的地址窗,經(jīng)常都能發(fā)現(xiàn)“cgi-bin”的字樣)。大多數(shù)語(yǔ)言都可用來(lái)編制這些程序,但其中最常見(jiàn)的是Perl。這是由于Perl是專為文字的處理及解釋而設(shè)計(jì)的,所以能在任何服務(wù)器上安裝和使用,無(wú)
71、論采用的處理器或操作系統(tǒng)是什么。</p><p><b> 2. 插件</b></p><p> 朝客戶端編程邁進(jìn)的時(shí)候,最重要的一個(gè)問(wèn)題就是插件的設(shè)計(jì)。利用插件,程序員可以方便地為瀏覽器添加新功能,用戶只需下載一些代碼,把它們“插入”瀏覽器的適當(dāng)位置即可。這些代碼的作用是告訴瀏覽器“從現(xiàn)在開(kāi)始,你可以進(jìn)行這些新活動(dòng)了”(僅需下載這些插入一次)。有些快速和功能強(qiáng)大
72、的行為是通過(guò)插件添加到瀏覽器的。但插件的編寫(xiě)并不是一件簡(jiǎn)單的任務(wù)。在我們構(gòu)建一個(gè)特定的站點(diǎn)時(shí),可能并不希望涉及這方面的工作。對(duì)客戶端程序設(shè)計(jì)來(lái)說(shuō),插件的價(jià)值在于它允許專業(yè)程序員設(shè)計(jì)出一種新的語(yǔ)言,并將那種語(yǔ)言添加到瀏覽器,同時(shí)不必經(jīng)過(guò)瀏覽器原創(chuàng)者的許可。由此可以看出,插件實(shí)際是瀏覽器的一個(gè)“后門(mén)”,允許創(chuàng)建新的客戶端程序設(shè)計(jì)語(yǔ)言(盡管并非所有語(yǔ)言都是作為插件實(shí)現(xiàn)的)。</p><p><b> 3.
73、腳本編制語(yǔ)言</b></p><p> 插件造成了腳本編制語(yǔ)言的爆炸性增長(zhǎng)。通過(guò)這種腳本語(yǔ)言,可將用于自己客戶端程序的源碼直接插入HTML頁(yè),而對(duì)那種語(yǔ)言進(jìn)行解釋的插件會(huì)在HTML頁(yè)顯示的時(shí)候自動(dòng)激活。腳本語(yǔ)言一般都傾向于盡量簡(jiǎn)化,易于理解。而且由于它們是從屬于HTML頁(yè)的一些簡(jiǎn)單正文,所以只需向服務(wù)器發(fā)出對(duì)那個(gè)頁(yè)的一次請(qǐng)求,即可非??斓剌d入。缺點(diǎn)是我們的代碼全部暴露在人們面前。另一方面,由于通常不
74、用腳本編制語(yǔ)言做過(guò)分復(fù)雜的事情,所以這個(gè)問(wèn)題暫且可以放在一邊。</p><p> 腳本語(yǔ)言真正面向的是特定類型問(wèn)題的解決,其中主要涉及如何創(chuàng)建更豐富、更具有互動(dòng)能力的圖形用戶界面(GUI)。然而,腳本語(yǔ)言也許能解決客戶端編程中80%的問(wèn)題。你碰到的問(wèn)題可能完全就在那80%里面。而且由于腳本編制語(yǔ)言的宗旨是盡可能地簡(jiǎn)化與快速,所以在考慮其他更復(fù)雜的方案之前(如Java及ActiveX),首先應(yīng)想一下腳本語(yǔ)言是否可
75、行。</p><p> 目前討論得最多的腳本編制語(yǔ)言包括JavaScript(它與Java沒(méi)有任何關(guān)系;之所以叫那個(gè)名字,完全是一種市場(chǎng)策略)、VBScript(同Visual Basic很相似)以及Tcl/Tk(來(lái)源于流行的跨平臺(tái)GUI構(gòu)造語(yǔ)言)。當(dāng)然還有其他許多語(yǔ)言,也有許多正在開(kāi)發(fā)中。</p><p> JavaScript也許是日常用的,它得到的支持也最全面。無(wú)論Netscap
76、eNavigator,Microsoft Internet Explorer,還是Opera,目前都提供了對(duì)JavaScript的支持。除此以外,市面上講述JavaScript的書(shū)籍也要比講述其他語(yǔ)言的書(shū)多得多。有些工具還能利用JavaScript自動(dòng)產(chǎn)生網(wǎng)頁(yè)。當(dāng)然,如果你已經(jīng)有Visual Basic或者Tcl/Tk的深厚功底,當(dāng)然用它們要簡(jiǎn)單得多,起碼可以避免學(xué)習(xí)新語(yǔ)言的煩惱(解決Web方面的問(wèn)題就已經(jīng)夠讓人頭痛了)。</p&
77、gt;<p><b> 4. Java</b></p><p> 如果說(shuō)一種腳本編制語(yǔ)言能解決80%的客戶端程序設(shè)計(jì)問(wèn)題,那么剩下的20%又該怎么辦呢?它們屬于一些高難度的問(wèn)題嗎?目前最流行的方案就是Java。它不僅是一種功能強(qiáng)大、高度安全、可以跨平臺(tái)使用以及國(guó)際通用的程序設(shè)計(jì)語(yǔ)言,也是一種具有旺盛生命力的語(yǔ)言。對(duì)Java的擴(kuò)展是不斷進(jìn)行的,提供的語(yǔ)言特性和庫(kù)能夠很好地解決
78、傳統(tǒng)語(yǔ)言不能解決的問(wèn)題,比如多線程操作、數(shù)據(jù)庫(kù)訪問(wèn)、連網(wǎng)程序設(shè)計(jì)以及分布式計(jì)算等等。Java通過(guò)“程序片”(Applet)巧妙地解決了客戶端編程的問(wèn)題。</p><p> 程序片(或“小應(yīng)用程序”)是一種非常小的程序,只能在Web瀏覽器中運(yùn)行。作為Web頁(yè)的一部分,程序片代碼會(huì)自動(dòng)下載回來(lái)(這和網(wǎng)頁(yè)中的圖片差不多)。激活程序片后,它會(huì)執(zhí)行一個(gè)程序。程序片的一個(gè)優(yōu)點(diǎn)體現(xiàn)在:通過(guò)程序片,一旦用戶需要客戶軟件,軟件就
79、可從服務(wù)器自動(dòng)下載回來(lái)。它們能自動(dòng)取得客戶軟件的最新版本,不會(huì)出錯(cuò),也沒(méi)有重新安裝的麻煩。由于Java的設(shè)計(jì)原理,程序員只需要?jiǎng)?chuàng)建程序的一個(gè)版本,那個(gè)程序能在幾乎所有計(jì)算機(jī)以及安裝了Java解釋器的瀏覽器中運(yùn)行。由于Java是一種全功能的編程語(yǔ)言,所以在向服務(wù)器發(fā)出一個(gè)請(qǐng)求之前,我們能先在客戶端做完盡可能多的工作。例如,再也不必通過(guò)因特網(wǎng)傳送一個(gè)請(qǐng)求表單,再由服務(wù)器確定其中是否存在一個(gè)拼寫(xiě)或者其他參數(shù)錯(cuò)誤。大多數(shù)數(shù)據(jù)校驗(yàn)工作均可在客戶端
80、完成,沒(méi)有必要坐在計(jì)算機(jī)前面焦急地等待服務(wù)器的響應(yīng)。這樣一來(lái),不僅速度和響應(yīng)的靈敏度得到了極大的提高,對(duì)網(wǎng)絡(luò)和服務(wù)器造成的負(fù)擔(dān)也可以明顯減輕,這對(duì)保障因特網(wǎng)的暢通是至關(guān)重要的。 與腳本程序相比,Java程序片的另一個(gè)優(yōu)點(diǎn)是它采用編譯好的形式,所以客戶端看不到源碼。當(dāng)然在另一方面,反編譯Java程序片也并不是件</p><p> 5. ActiveX</p><p> 在某種程度
81、上,Java的一個(gè)有力競(jìng)爭(zhēng)對(duì)手應(yīng)該是微軟的ActiveX,盡管它采用的是完全不同的一套實(shí)現(xiàn)機(jī)制。ActiveX最早是一種純Windows的方案。經(jīng)過(guò)一家獨(dú)立的專業(yè)協(xié)會(huì)的努力,ActiveX現(xiàn)在已具備了跨平臺(tái)使用的能力。實(shí)際上,ActiveX的意思是“假如你的程序同它的工作環(huán)境正常連接,它就能進(jìn)入Web頁(yè),并在支持ActiveX的瀏覽器中運(yùn)行”(IE固化了對(duì)ActiveX的支持,而Netscape需要一個(gè)插件)。所以,ActiveX并沒(méi)有
82、限制我們使用一種特定的語(yǔ)言。比如,假設(shè)我們已經(jīng)是一名有經(jīng)驗(yàn)的Windows程序員,能熟練地使用像C++、Visual Basic或者Borland Delphi那樣的語(yǔ)言,就能幾乎不加任何學(xué)習(xí)地創(chuàng)建出ActiveX組件。事實(shí)上,ActiveX是在我們的Web頁(yè)中使用“歷史遺留”代碼的最佳途徑。</p><p><b> 6. 安全</b></p><p> 自動(dòng)下
83、載和通過(guò)因特網(wǎng)運(yùn)行程序聽(tīng)起來(lái)就像是一個(gè)病毒制造者的夢(mèng)想。在客戶端的編程中,ActiveX帶來(lái)了最讓人頭痛的安全問(wèn)題。點(diǎn)擊一個(gè)Web站點(diǎn)的時(shí)候,可能會(huì)隨同HTML網(wǎng)頁(yè)傳回任何數(shù)量的東西:GIF文件、腳本代碼、編譯好的Java代碼以及ActiveX組件。有些是無(wú)害的;GIF文件不會(huì)對(duì)我們?cè)斐扇魏挝:Γ_本編制語(yǔ)言通常在自己可做的事情上有著很大的限制。Java也設(shè)計(jì)成在一個(gè)安全“沙箱”里在它的程序片中運(yùn)行,這樣可防止操作位于沙箱以外的磁盤(pán)或
84、者內(nèi)存區(qū)域。</p><p> ActiveX是所有這些里面最讓人擔(dān)心的。用ActiveX編寫(xiě)程序就像編制Windows應(yīng)用程序——可以做自己想做的任何事情。下載回一個(gè)ActiveX組件后,它完全可能對(duì)我們磁盤(pán)上的文件造成破壞。當(dāng)然,對(duì)那些下載回來(lái)并不限于在Web瀏覽器內(nèi)部運(yùn)行的程序,它們同樣也可能破壞我們的系統(tǒng)。從BBS下載回來(lái)的病毒一直是個(gè)大問(wèn)題,但因特網(wǎng)的速度使得這個(gè)問(wèn)題變得更加復(fù)雜。 目前解決的
85、辦法是“數(shù)字簽名”,代碼會(huì)得到權(quán)威機(jī)構(gòu)的驗(yàn)證,顯示出它的作者是誰(shuí)。這一機(jī)制的基礎(chǔ)是認(rèn)為病毒之所以會(huì)傳播,是由于它的編制者匿名的緣故。所以假如去掉了匿名的因素,所有設(shè)計(jì)者都不得不為它們的行為負(fù)責(zé)。這似乎是一個(gè)很好的主意,因?yàn)樗钩绦蝻@得更加正規(guī)。但我對(duì)它能消除惡意因素持懷疑態(tài)度,因?yàn)榧偃缫粋€(gè)程序便含有Bug,那么同樣會(huì)造成問(wèn)題。</p><p> Java通過(guò)“沙箱”來(lái)防止這些問(wèn)題的發(fā)生。Java解釋器內(nèi)嵌于我們
86、本地的Web瀏覽器中,在程序片裝載時(shí)會(huì)檢查所有有嫌疑的指令。特別地,程序片根本沒(méi)有權(quán)力將文件寫(xiě)進(jìn)磁盤(pán),或者刪除文件(這是病毒最喜歡做的事情之一)。我們通常認(rèn)為程序片是安全的。而且由于安全對(duì)于營(yíng)建一套可靠的客戶機(jī)/服務(wù)器系統(tǒng)至關(guān)重要,所以會(huì)給病毒留下漏洞的所有錯(cuò)誤都能很快得到修復(fù)(瀏覽器軟件實(shí)際需要強(qiáng)行遵守這些安全規(guī)則;而有些瀏覽器則允許我們選擇不同的安全級(jí)別,防止對(duì)系統(tǒng)不同程度的訪問(wèn))。</p><p> 大家
87、或許會(huì)懷疑這種限制是否會(huì)妨礙我們將文件寫(xiě)到本地磁盤(pán)。比如,我們有時(shí)需要構(gòu)建一個(gè)本地?cái)?shù)據(jù)庫(kù),或?qū)?shù)據(jù)保存下來(lái),以便日后離線使用。最早的版本似乎每個(gè)人都能在線做任何敏感的事情,但這很快就變得非常不現(xiàn)實(shí)(盡管低價(jià)“互聯(lián)網(wǎng)工具”有一天可能會(huì)滿足大多數(shù)用戶的需要)。解決的方案是“簽了名的程序片”,它用公共密鑰加密算法驗(yàn)證程序片確實(shí)來(lái)自它所聲稱的地方。當(dāng)然在通過(guò)驗(yàn)證后,簽了名的一個(gè)程序片仍然可以開(kāi)始清除你的磁盤(pán)。但從理論上說(shuō),既然現(xiàn)在能夠找到創(chuàng)建人
88、“算帳”,他們一般不會(huì)干這種蠢事。Java 1.1為數(shù)字簽名提供了一個(gè)框架,在必要時(shí),可讓一個(gè)程序片“走”到沙箱的外面來(lái)。</p><p> 數(shù)字簽名遺漏了一個(gè)重要的問(wèn)題,那就是人們?cè)谝蛱鼐W(wǎng)上移動(dòng)的速度。如下載回一個(gè)錯(cuò)誤百出的程序,而它很不幸地真的干了某些蠢事,需要多久的時(shí)間才能發(fā)覺(jué)這一點(diǎn)呢?這也許是幾天,也可能幾周之后。發(fā)現(xiàn)了之后,又如何追蹤當(dāng)初肇事的程序呢(以及它當(dāng)時(shí)的責(zé)任有多大)?</p>
89、<p> 7. 因特網(wǎng)和內(nèi)聯(lián)網(wǎng)</p><p> Web是解決客戶機(jī)/服務(wù)器問(wèn)題的一種常用方案,所以最好能用相同的技術(shù)解決此類問(wèn)題的一些“子集”,特別是公司內(nèi)部的傳統(tǒng)客戶機(jī)/服務(wù)器問(wèn)題。對(duì)于傳統(tǒng)的客戶機(jī)/服務(wù)器模式,我們面臨的問(wèn)題是擁有多種不同類型的客戶計(jì)算機(jī),而且很難安裝新的客戶軟件。但通過(guò)Web瀏覽器和客戶端編程,這兩類問(wèn)題都可得到很好的解決。若一個(gè)信息網(wǎng)絡(luò)局限于一家特定的公司,那么在將Web技
90、術(shù)應(yīng)用于它之后,即可稱其為“內(nèi)聯(lián)網(wǎng)”(Intranet),以示與國(guó)際性的“因特網(wǎng)”(Internet)有別。內(nèi)聯(lián)網(wǎng)提供了比因特網(wǎng)更高的安全級(jí)別,因?yàn)榭梢晕锢硇缘乜刂茖?duì)公司內(nèi)部服務(wù)器的使用。說(shuō)到培訓(xùn),一般只要人們理解了瀏覽器的常規(guī)概念,就可以非常輕松地掌握網(wǎng)頁(yè)和程序片之間的差異,所以學(xué)習(xí)新型系統(tǒng)的開(kāi)銷會(huì)大幅度減少。</p><p> 安全問(wèn)題將我們引入客戶端編程領(lǐng)域一個(gè)似乎是自動(dòng)形成的分支。若程序是在因特網(wǎng)上運(yùn)行
91、,由于無(wú)從知曉它會(huì)在什么平臺(tái)上運(yùn)行,所以編程時(shí)要特別留意,防范可能出現(xiàn)的編程錯(cuò)誤。需作一些跨平臺(tái)處理,以及適當(dāng)?shù)陌踩婪?,比如采用某種腳本語(yǔ)言或者Java。</p><p> 但假如在內(nèi)聯(lián)網(wǎng)中運(yùn)行,面臨的一些制約因素就會(huì)發(fā)生變化。全部機(jī)器均為Intel/Windows平臺(tái)是件很平常的事情。在內(nèi)聯(lián)網(wǎng)中,需要對(duì)自己代碼的質(zhì)量負(fù)責(zé)。而且一旦發(fā)現(xiàn)錯(cuò)誤,就可以馬上改正。除此以外,可能已經(jīng)有了一些“歷史遺留”的代碼,并用較
92、傳統(tǒng)的客戶機(jī)/服務(wù)器方式使用那些代碼。但在進(jìn)行升級(jí)時(shí),每次都要物理性地安裝一道客戶程序。浪費(fèi)在升級(jí)安裝上的時(shí)間是轉(zhuǎn)移到瀏覽器的一項(xiàng)重要原因。使用了瀏覽器后,升級(jí)就變得易如反掌,而且整個(gè)過(guò)程是透明和自動(dòng)進(jìn)行的。如果真的是牽涉到這樣的一個(gè)內(nèi)聯(lián)網(wǎng)中,最明智的方法是采用ActiveX,而非試圖采用一種新的語(yǔ)言來(lái)改寫(xiě)程序代碼。</p><p> 面臨客戶端編程問(wèn)題令人困惑的一系列解決方案時(shí),最好的方案是先做一次投資/回報(bào)
93、分析。請(qǐng)總結(jié)出問(wèn)題的全部制約因素,以及什么才是最快的方案。由于客戶端程序設(shè)計(jì)仍然要編程,所以無(wú)論如何都該針對(duì)自己的特定情況采取最好的開(kāi)發(fā)途徑。這是準(zhǔn)備面對(duì)程序開(kāi)發(fā)中一些不可避免的問(wèn)題時(shí),我們可以做出的最佳姿態(tài)。</p><p><b> 8服務(wù)器端編程</b></p><p> 我們的整個(gè)討論都忽略了服務(wù)器端編程的問(wèn)題。如果向服務(wù)器發(fā)出一個(gè)請(qǐng)求,會(huì)發(fā)生什么事情?大
94、多數(shù)時(shí)候的請(qǐng)求都是很簡(jiǎn)單的一個(gè)“把這個(gè)文件發(fā)給我”。瀏覽器隨后會(huì)按適當(dāng)?shù)男问浇忉屵@個(gè)文件:作為HTML頁(yè)、一幅圖、一個(gè)Java程序片、一個(gè)腳本程序等等。向服務(wù)器發(fā)出的較復(fù)雜的請(qǐng)求通常涉及到對(duì)一個(gè)數(shù)據(jù)庫(kù)進(jìn)行操作(事務(wù)處理)。其中最常見(jiàn)的就是發(fā)出一個(gè)數(shù)據(jù)庫(kù)檢索命令,得到結(jié)果后,服務(wù)器會(huì)把它格式化成HTML頁(yè),并作為結(jié)果傳回來(lái)(當(dāng)然,假如客戶通過(guò)Java或者某種腳本語(yǔ)言具有了更高的智能,那么原始數(shù)據(jù)就能在客戶端發(fā)送和格式化;這樣做速度可以更快
95、,也能減輕服務(wù)器的負(fù)擔(dān))。另外,有時(shí)需要在數(shù)據(jù)庫(kù)中注冊(cè)自己的名字(比如加入一個(gè)組時(shí)),或者向服務(wù)器發(fā)出一份訂單,這就涉及到對(duì)那個(gè)數(shù)據(jù)庫(kù)的修改。這類服務(wù)器請(qǐng)求必須通過(guò)服務(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ù)器端編程,寫(xiě)出的程序就叫做“小服務(wù)程序”(Servlet)。</p
96、><p> 9.一個(gè)獨(dú)立的領(lǐng)域:應(yīng)用程序</p><p> 與Java有關(guān)的大多數(shù)爭(zhēng)論都是與程序片有關(guān)的。Java實(shí)際是一種常規(guī)用途的程序設(shè)計(jì)語(yǔ)言,可解決任何類型的問(wèn)題,至少理論上如此。而且正如前面指出的,可以用更有效的方式來(lái)解決大多數(shù)客戶機(jī)/服務(wù)器問(wèn)題。如果將視線從程序片身上轉(zhuǎn)開(kāi)(同時(shí)放寬一些限制,比如禁止寫(xiě)盤(pán)等),就進(jìn)入了常規(guī)用途的應(yīng)用程序的廣闊領(lǐng)域。這種應(yīng)用程序可獨(dú)立運(yùn)行,毋需瀏覽器
97、,就象普通的執(zhí)行程序那樣。在這兒,Java的特色并不僅僅反應(yīng)在它的移植能力,也反映在編程本身上。就像貫穿全書(shū)都會(huì)講到的那樣,Java提供了許多有用的特性,使我們能在較短的時(shí)間里創(chuàng)建出比用從前的程序設(shè)計(jì)語(yǔ)言更健壯的程序。</p><p> 但要注意任何東西都不是十全十美的,我們?yōu)榇艘惨冻鲆恍┐鷥r(jià)。其中最明顯的是執(zhí)行速度放慢了(盡管可對(duì)此進(jìn)行多方面的調(diào)整)。和任何語(yǔ)言一樣,Java本身也存在一些限制,使得它不十分
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 眾賞文庫(kù)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- java思想外文翻譯---java編程思想 (java和因特網(wǎng))
- java和因特網(wǎng)外文翻譯
- 畢業(yè)論文外文翻譯-java和因特網(wǎng)
- java和因特網(wǎng)
- java 外文翻譯
- java外文翻譯
- java介紹外文翻譯
- java 編程外文翻譯
- java介紹外文翻譯
- java的基礎(chǔ)外文翻譯
- java外文文獻(xiàn)翻譯
- 外文翻譯--java技術(shù)介紹
- 外文翻譯---java學(xué)習(xí)過(guò)程
- 外文翻譯---java的思考
- java相關(guān)外文翻譯
- java io系統(tǒng)外文翻譯
- java io 系統(tǒng)外文翻譯
- 外文翻譯-java設(shè)計(jì)和zos的開(kāi)發(fā)應(yīng)用
- JAVA外文文獻(xiàn)+翻譯.doc
- java相關(guān)畢業(yè)論文外文翻譯
評(píng)論
0/150
提交評(píng)論