《毕业论文外文翻译-Java 和Internet.doc》由会员分享,可在线阅读,更多相关《毕业论文外文翻译-Java 和Internet.doc(10页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
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.Python.org) 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只是一种新的计算机编程语言的话(实际上这话也没错),它为什么会那么重要,为什么会被除数拔高到“计算机编程领域的革
43、命性的进步”,这个高度。如果你是从传统编程的立场上来看这个问题,也许答案还不是那么有说服力。尽管在解决传统的,孤立的编程问题方面,Java也是很能干的,但是真正让它脱颖而出的,是因为它能解决在万维网上编程的问题。Web就什么?刚开始的时候,Web看上去很神秘,大家都江堰市在谈冲浪、在线、主页什么的。要把讲Web讲清楚,最好是退回来从头开始。但是这么做,先得理解客户/服务器系统。这是计算机技术的另一个领域,里面也有大把让人头晕的问题。客户/服务器系统客户机/服务器系统的主要思想是,你有一个中央信息库通常是保存在数据库中的一些信息要根据需要,把它们分配给某些人或机器。客户机/服务器系统的关键在于,
44、信息库会集中管理信息,因此信息的修改能够传播到用户那里。信息库,分发信息的软件,以及存储信息的软件的机器合起来称为服务器。存储在远程机器上的软件会同这个服务器通讯,提取信息,处理信息,并且在过程机器上显示结果。这被除数称为客户。这么看来,客户/服务器计算机的基本概念没那么复杂。但是,当你试图用孤零零的一个服务器来为很多客户服务的时候,问题就来了。这个架构通常都会牵扯到数据库管理系统,所以为了优化应用,设计人员会去“平衡”数据的格式。此外,通常系统还允许客户往服务器里插入新的数据。这就意味着你必须保证一个客户的新数据不会和另一个客户的新数据搅在一起,以及数据不会在添加的过程中遗失(这被称为事务处
45、理)。当客户端的程序修改之后,还必须重新编译,调试并且安装到客户机上,这要比你想像的复杂昂贵得多。而且如果要支持多种机器或操作系统的话,事情会更麻烦。最后还有一个最重要的性能问题:服务器可能会同时响应成百上千个客户,所以再小的耽搁都是很要命的。为了把延时降到最低,程序员们尽量减轻服务的负载,通常会把这些处理任务挪到客户端,不过有时也会移到所谓的中间件的服务器上。(中间件也被用来增进系统的可维护性。)分发数据这个简单的思想竟然会引出这么些复杂层次,而所有这些问题看起来都像是根本不可能解开的谜。但还有更重要的:大约有一半的开发项目都是基于客户/服务器架构的。它们包括像接收订单,信用卡交易额以及分发
46、各种各样的数据股票市场的,科研的,政府部门的,只要你能叫的上名字的。以前我们的作法是为每个问题设计不同的解决方案,每次都发明一种新方法。这种项目开发起来难,用户用起来也不方便,它们必须适应新的界面。客户/服务器架构这个问题必须要能在总体上解决。把Web当作巨型的服务器Web实际上就是一个巨型的客户/服务器系统。实际上还差一点,因为所有的服务器和客户机是共存在同一个网络上的。不过这点你并不知道,因为你只关心是不是能连到那台服务器,并且对它进行操作(尽管你可能得先在什么地方找到那台服务器)。最初这只是个关向过程。你向服务器提请求,它交给你一个文件,然后你用本地机上的浏览器(也就是客户)来解释这个文
47、件并且为它重新排版。但没过多久,人们就不满足于仅仅从服务器收发文件了。他们需要完整的客户/服务器功能,所以客户也能向服务器发送信息了,比如查询服务器端的数据库,向服务器添加新的信息,或者下单(这项任务所要求的安全性比系统原先能提供的要高得多)。这些就是我们在Web的发展历程中亲眼目睹的变化。Web浏览器是一项巨大的进步:它的思想是要让同样的信息以通常的形式显示在所有的机器上。然而浏览器还是太原始了一些,而且也很快被加在它身上的任务给拖垮了。它的互动性不好,而且所有需要编程解决的任务都要交到服务器上去处理,所以经常会把服务器和Internet给堵了。有时可能会花几秒钟,甚至是几分钟,才会发现提交
48、的请求里面有一个拼写错误。由于浏览器只是用来显示,不能承担哪怕是最简单的计算任务。(另一方面这样也很安全,因为它不会在你的本地机上执行可能包含bug或病毒程序。)为了解决这个问题,人们用了很多办法。开始是升级图形超标准,让浏览器能显示效果更佳的动画和视频。但是有些问题,只能通过让客户端的浏览器运行程序来解决了。这被称为客户端编程。客户端编程Web最初的服务器浏览器设计提供了互动内容,但是这种互动性是完全建立在服务器之上的。服务器为客户端提供静态页面,而浏览器只是简单的解释页面,然后显示出来。HTML包括了基本的数据采集功能:输入框,复选框,单选按钮,列表,下拉式列表,以及只能用于清除表单或是把
49、表单数据“提交”给服务器的按扭。提交上来的数据会交给Web服务器上的通用网关接口程序。这些文本会告诉CGI该做些什么。最常见的就是在服务器上运行一个程序,这个程序一般会放在“cgi-bin”目录中。(如果按完Web页面上的按扭之后,你仔细观察浏览器顶部的地址条的话,有时你就会在那些不知所云的东西中看到“cgi-bin”。)大多数语言都可以写这些程序。Perl是最常用的,因为它设计的目的就是为了处理和解释文本,所以不论服务器用的是那种处理器,或是那种操作系统,都能安装Perl。但Python(我的最爱见www.Pythoin.org)由于其功能强大简单易用,已经对Perl的霸主地位发起了挑战。很多大型网站都是完全建立在CGI之上的,而且实际上你能用CGI来做几乎任何事情。但是建立在CGI之上的网站会很快变得过于复杂而难以维护,此处还有一个相应时间的问题。CGI程序的相应时间取决于它要发送多少数据,以及服务器端各Internet的负载。(而且CGI程序本身就启动很慢。)最初设计Web的人没能预