計算機外文翻譯 (5)_第1頁
計算機外文翻譯 (5)_第2頁
計算機外文翻譯 (5)_第3頁
計算機外文翻譯 (5)_第4頁
計算機外文翻譯 (5)_第5頁
已閱讀5頁,還剩3頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、Java and the InternetIf 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 programming. The answer isnt immediately obvious if youre coming from a traditional programming perspective. A

2、lthough Java is very useful for solving traditional standalone programming problems, it is also important because it will solve programming problems on the World Wide Web.What is the Web?The Web can seem a bit of a mystery at first, with all this talk of “surfing,” “presence,” and “home pages.” Its

3、helpful to step back and see what it really is, but to do this you must understand client/server systems, another aspect of computing thats full of confusing issues.Client/Server computingThe primary idea of a client/server system is that you have a central repository of informationsome kind of data

4、, often in a databasethat you want to distribute on demand to some set of people or machines. A key to the client/server concept is that the repository of information is centrally located so that it can be changed and so that those changes will propagate out to the information consumers. Taken toget

5、her, the information repository, the software that distributes the information and the machine where the information and software reside is called the server. The software that resides on the remote machine, communicates with the server, fetches the information, processes it, and then displays it on

6、 the remote machine is called the client.The basic concept of client/server computing, then, is not so complicated. The problems arise because you have a single server trying to serve many clients at once. Generally, a database management system is involved, so the designer “balances” the layout of

7、data into tables for optimal use. In addition, systems often allow a client to insert new information into a server. This means you must ensure that one clients new data doesnt walk over another clients new data, or that data isnt lost in the process of adding it to the database (this is called tran

8、saction processing). As client software changes, it must be built, debugged, and installed on the client machines, which turns out to be more complicated and expensive than you might think. Its especially problematic to support multiple types of computers and operating systems. Finally, theres the a

9、ll-important performance issue: You might have hundreds of clients making requests of your server at any one time, so any small delay is crucial. To minimize latency, programmers work hard to offload processing tasks, often to the client machine, but sometimes to other machines at the server site, u

10、sing so-called middleware. (Middleware is also used to improve maintainability.)The simple idea of distributing information has so many layers of complexity that the whole problem can seem hopelessly enigmatic. And yet its crucial: Client/server computing accounts for roughly half of all programming

11、 activities. Its responsible for everything from taking orders and credit-card transactions to the distribution of any kind of datastock market, scientific, government, you name it. What weve come up with in the past is individual solutions to individual problems, inventing a new solution each time.

12、 These were hard to create and hard to use, and the user had to learn a new interface for each one. The entire client/server problem needs to be solved in a big way.The Web as a giant serverThe Web is actually one giant client/server system. Its a bit worse than that, since you have all the servers

13、and clients coexisting on a single network at once. You dont need to know that, because all you care about is connecting to and interacting with one server at a time (even though you might be hopping around the world in your search for the correct server).Initially it was a simple one-way process. Y

14、ou made a request of a server and it handed you a file, which your machines browser software (i.e., the client) would interpret by formatting onto your local machine. But in short order people began wanting to do more than just deliver pages from a server. They wanted full client/server capability s

15、o that the client could feed information back to the server, for example, to do database lookups on the server, to add new information to the server, or to place an order (which required more security than the original systems offered). These are the changes weve been seeing in the development of th

16、e Web.The Web browser was a big step forward: the concept that one piece of information could be displayed on any type of computer without change. However, browsers were still rather primitive and rapidly bogged down by the demands placed on them. They werent particularly interactive, and tended to

17、clog up both the server and the Internet because any time you needed to do something that required programming you had to send information back to the server to be processed. It could take many seconds or minutes to find out you had misspelled something in your request. Since the browser was just a

18、viewer it couldnt perform even the simplest computing tasks. (On the other hand, it was safe, because it couldnt execute any programs on your local machine that might contain bugs or viruses.)To solve this problem, different approaches have been taken. To begin with, graphics standards have been enh

19、anced to allow better animation and video within browsers. The remainder of the problem can be solved only by incorporating the ability to run programs on the client end, under the browser. This is called client-side programming.Client-side programmingThe Webs initial server-browser design provided

20、for interactive content, but the interactivity was completely provided by the server. The server produced static pages for the client browser, which would simply interpret and display them. Basic HyperText Markup Language (HTML) contains simple mechanisms for data gathering: text-entry boxes, check

21、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. This submission passes through the Common Gateway Interface (CGI) provided on all Web servers. The text within the submiss

22、ion tells CGI what to do with it. The most common action is to run a program located on the server in a directory thats typically called “cgi-bin.” (If you watch the address window at the top of your browser when you push a button on a Web page, you can sometimes see “cgi-bin” within all the gobbled

23、ygook there.) These programs can be written in most languages. Perl has been a common choice because it is designed for text manipulation and is interpreted, so it can be installed on any server regardless of processor or operating system. However, Python (my favoritesee www.P) has been mak

24、ing inroads because of its greater power and simplicity.Many powerful Web sites today are built strictly on CGI, and you can in fact do nearly anything with CGI. However, Web sites built on CGI programs can rapidly become overly complicated to maintain, and there is also the problem of response time

25、. 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 designers of the Web did not foresee how rapidly this bandwidth would be exhausted for the kinds of a

26、pplications people developed. For example, any sort of dynamic graphing is nearly impossible to perform with consistency because a Graphics Interchange Format (GIF) file must be created and moved from the server to the client for each version of the graph. And youve no doubt had direct experience wi

27、th something as simple as validating the data on an input form. You press the submit button on a page; the data is shipped back to the server; the server starts a CGI program that discovers an error, formats an HTML page informing you of the error, and then sends the page back to you; you must then

28、back up a page and try again. Not only is this slow, its inelegant.The solution is client-side programming. Most machines that run Web browsers are powerful engines capable of doing vast work, and with the original static HTML approach they are sitting there, just idly waiting for the server to dish

29、 up the next page. Client-side programming means that the Web browser is harnessed to do whatever work it can, and the result for the user is a much speedier and more interactive experience at your Web site.The problem with discussions of client-side programming is that they arent very different fro

30、m discussions of programming 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 and solutions produced by client-side programming. Th

31、e rest of this section provides an overview of the issues and approaches in client-side programming.Plug-insOne 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

32、piece of code that plugs itself 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-ins, but writing a plug-in is not a trivial task

33、, and isnt something youd want 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 allows an expert programmer to develop a new language and add that language to a browser without the permission of the browser manufacturer. Thus

34、, plug-ins provide a “back door” that allows the creation of new client-side programming languages (although not all languages are implemented as plug-ins).Scripting languagesPlug-ins resulted in an explosion of scripting languages. With a scripting language, you embed the source code for your clien

35、t-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 easy to understand and, because they are simply text that is part of an HTML page, they load very qui

36、ckly as part of the single server hit required to procure that page. The trade-off is that your code is exposed for everyone to see (and steal). Generally, however, you arent doing amazingly sophisticated things with scripting languages, so this is not too much of a hardship.This points out that the

37、 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 language might solve 80 percent of the problems encountered in client-side programming.

38、Your problems might very well fit completely within that 80 percent, and since scripting languages can allow easier and faster development, you should probably consider a scripting language before looking at a more involved solution such as Java or ActiveX programming.The most commonly discussed bro

39、wser scripting languages are JavaScript (which has nothing to do with Java; its named that way just to grab some of Javas 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 d

40、oubt more in development.JavaScript is probably the most commonly supported. It comes built into both Netscape Navigator and the Microsoft Internet Explorer (IE). Unfortunately, the flavor of JavaScript on the two browsers can vary widely (the Mozilla browser, freely downloadable from www.Mozilla.or

41、g, supports the ECMAScript standard, which may one day become universally supported). In addition, there are probably more JavaScript books available than there are for the other browser languages, and some tools automatically create pages using JavaScript. However, if youre already fluent in Visual

42、 BASIC or Tcl/Tk, youll be more productive using those scripting languages rather than learning a new one. (Youll have your hands full dealing with the Web issues already.)原文來源:(美)Bruce Ecket. Thinking in JAVA第三版. 2003Java 和Internet可能你會問,如果Java只是一種新的計算機編程語言的話(實際上這話也沒錯),它為什么會那么重要,為什么會被除數(shù)拔高到“計算機編程領(lǐng)域的革

43、命性的進步”,這個高度。如果你是從傳統(tǒng)編程的立場上來看這個問題,也許答案還不是那么有說服力。盡管在解決傳統(tǒng)的,孤立的編程問題方面,Java也是很能干的,但是真正讓它脫穎而出的,是因為它能解決在萬維網(wǎng)上編程的問題。Web就什么?剛開始的時候,Web看上去很神秘,大家都江堰市在談沖浪、在線、主頁什么的。要把講Web講清楚,最好是退回來從頭開始。但是這么做,先得理解客戶/服務器系統(tǒng)。這是計算機技術(shù)的另一個領(lǐng)域,里面也有大把讓人頭暈的問題??蛻?服務器系統(tǒng)客戶機/服務器系統(tǒng)的主要思想是,你有一個中央信息庫通常是保存在數(shù)據(jù)庫中的一些信息要根據(jù)需要,把它們分配給某些人或機器。客戶機/服務器系統(tǒng)的關(guān)鍵在于,

44、信息庫會集中管理信息,因此信息的修改能夠傳播到用戶那里。信息庫,分發(fā)信息的軟件,以及存儲信息的軟件的機器合起來稱為服務器。存儲在遠程機器上的軟件會同這個服務器通訊,提取信息,處理信息,并且在過程機器上顯示結(jié)果。這被除數(shù)稱為客戶。這么看來,客戶/服務器計算機的基本概念沒那么復雜。但是,當你試圖用孤零零的一個服務器來為很多客戶服務的時候,問題就來了。這個架構(gòu)通常都會牽扯到數(shù)據(jù)庫管理系統(tǒng),所以為了優(yōu)化應用,設(shè)計人員會去“平衡”數(shù)據(jù)的格式。此外,通常系統(tǒng)還允許客戶往服務器里插入新的數(shù)據(jù)。這就意味著你必須保證一個客戶的新數(shù)據(jù)不會和另一個客戶的新數(shù)據(jù)攪在一起,以及數(shù)據(jù)不會在添加的過程中遺失(這被稱為事務處

45、理)。當客戶端的程序修改之后,還必須重新編譯,調(diào)試并且安裝到客戶機上,這要比你想像的復雜昂貴得多。而且如果要支持多種機器或操作系統(tǒng)的話,事情會更麻煩。最后還有一個最重要的性能問題:服務器可能會同時響應成百上千個客戶,所以再小的耽擱都是很要命的。為了把延時降到最低,程序員們盡量減輕服務的負載,通常會把這些處理任務挪到客戶端,不過有時也會移到所謂的中間件的服務器上。(中間件也被用來增進系統(tǒng)的可維護性。)分發(fā)數(shù)據(jù)這個簡單的思想竟然會引出這么些復雜層次,而所有這些問題看起來都像是根本不可能解開的謎。但還有更重要的:大約有一半的開發(fā)項目都是基于客戶/服務器架構(gòu)的。它們包括像接收訂單,信用卡交易額以及分發(fā)

46、各種各樣的數(shù)據(jù)股票市場的,科研的,政府部門的,只要你能叫的上名字的。以前我們的作法是為每個問題設(shè)計不同的解決方案,每次都發(fā)明一種新方法。這種項目開發(fā)起來難,用戶用起來也不方便,它們必須適應新的界面。客戶/服務器架構(gòu)這個問題必須要能在總體上解決。把Web當作巨型的服務器Web實際上就是一個巨型的客戶/服務器系統(tǒng)。實際上還差一點,因為所有的服務器和客戶機是共存在同一個網(wǎng)絡(luò)上的。不過這點你并不知道,因為你只關(guān)心是不是能連到那臺服務器,并且對它進行操作(盡管你可能得先在什么地方找到那臺服務器)。最初這只是個關(guān)向過程。你向服務器提請求,它交給你一個文件,然后你用本地機上的瀏覽器(也就是客戶)來解釋這個文

47、件并且為它重新排版。但沒過多久,人們就不滿足于僅僅從服務器收發(fā)文件了。他們需要完整的客戶/服務器功能,所以客戶也能向服務器發(fā)送信息了,比如查詢服務器端的數(shù)據(jù)庫,向服務器添加新的信息,或者下單(這項任務所要求的安全性比系統(tǒng)原先能提供的要高得多)。這些就是我們在Web的發(fā)展歷程中親眼目睹的變化。Web瀏覽器是一項巨大的進步:它的思想是要讓同樣的信息以通常的形式顯示在所有的機器上。然而瀏覽器還是太原始了一些,而且也很快被加在它身上的任務給拖垮了。它的互動性不好,而且所有需要編程解決的任務都要交到服務器上去處理,所以經(jīng)常會把服務器和Internet給堵了。有時可能會花幾秒鐘,甚至是幾分鐘,才會發(fā)現(xiàn)提交

48、的請求里面有一個拼寫錯誤。由于瀏覽器只是用來顯示,不能承擔哪怕是最簡單的計算任務。(另一方面這樣也很安全,因為它不會在你的本地機上執(zhí)行可能包含bug或病毒程序。)為了解決這個問題,人們用了很多辦法。開始是升級圖形超標準,讓瀏覽器能顯示效果更佳的動畫和視頻。但是有些問題,只能通過讓客戶端的瀏覽器運行程序來解決了。這被稱為客戶端編程??蛻舳司幊蘔eb最初的服務器瀏覽器設(shè)計提供了互動內(nèi)容,但是這種互動性是完全建立在服務器之上的。服務器為客戶端提供靜態(tài)頁面,而瀏覽器只是簡單的解釋頁面,然后顯示出來。HTML包括了基本的數(shù)據(jù)采集功能:輸入框,復選框,單選按鈕,列表,下拉式列表,以及只能用于清除表單或是把

49、表單數(shù)據(jù)“提交”給服務器的按扭。提交上來的數(shù)據(jù)會交給Web服務器上的通用網(wǎng)關(guān)接口程序。這些文本會告訴CGI該做些什么。最常見的就是在服務器上運行一個程序,這個程序一般會放在“cgi-bin”目錄中。(如果按完Web頁面上的按扭之后,你仔細觀察瀏覽器頂部的地址條的話,有時你就會在那些不知所云的東西中看到“cgi-bin”。)大多數(shù)語言都可以寫這些程序。Perl是最常用的,因為它設(shè)計的目的就是為了處理和解釋文本,所以不論服務器用的是那種處理器,或是那種操作系統(tǒng),都能安裝Perl。但Python(我的最愛見www.P)由于其功能強大簡單易用,已經(jīng)對Perl的霸主地位發(fā)起了挑戰(zhàn)。很多大型網(wǎng)站都是完全建立在C

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 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

提交評論