【正文】
on tells CGI what to do with it. The most mon action is to run a program located on the server in a directory that’s typically called “cgibin.” (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 “cgibin” within all the gobbledygook there.) These programs can be written in most languages. Perl has been a mon 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 favorite—see ) has been making 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 bee overly plicated to maintain, and there is also the problem 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 initial designers of the Web did not foresee how rapidly this bandwidth would be exhausted for the kinds of applications 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 you’ve no doubt had direct experience with something as simple as validating the data on an input form. You press the submit button on a page。 you must then back up a page and try again. Not only is this slow, it’s inelegant.The solution is clientside 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 up the next page. Clientside 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 clientside programming is that they aren’t very different from discussions of programming in general. The parameters are almost the same, but the platform is different。原文來(lái)源:(美)Bruce Ecket. Thinking in JAVA第三版. 2003Web就什么?剛開(kāi)始的時(shí)候,Web看上去很神秘,大家都江堰市在談沖浪、在線、主頁(yè)什么的??蛻?hù)/服務(wù)器系統(tǒng)客戶(hù)機(jī)/服務(wù)器系統(tǒng)的主要思想是,你有一個(gè)中央信息庫(kù)———通常是保存在數(shù)據(jù)庫(kù)中的一些信息———要根據(jù)需要,把它們分配給某些人或機(jī)器。這被除數(shù)稱(chēng)為客戶(hù)。此外,通常系統(tǒng)還允許客戶(hù)往服務(wù)器里插入新的數(shù)據(jù)。最后還有一個(gè)最重要的性能問(wèn)題:服務(wù)器可能會(huì)同時(shí)響應(yīng)成百上千個(gè)客戶(hù),所以再小的耽擱都是很要命的。但還有更重要的:大約有一半的開(kāi)發(fā)項(xiàng)目都是基于客戶(hù)/服務(wù)器架構(gòu)的??蛻?hù)/服務(wù)器架構(gòu)這個(gè)問(wèn)題必須要能在總體上解決。最初這只是個(gè)關(guān)向過(guò)程。這些就是我們?cè)赪eb的發(fā)展歷程中親眼目睹的變化。有時(shí)可能會(huì)花幾秒鐘,甚至是幾分鐘,才會(huì)發(fā)現(xiàn)提交的請(qǐng)求里面有一個(gè)拼寫(xiě)錯(cuò)誤。開(kāi)始是升級(jí)圖形超標(biāo)準(zhǔn),讓瀏覽器能顯示效果更佳的動(dòng)畫(huà)和視頻??蛻?hù)端編程Web最初的服務(wù)器——瀏覽器設(shè)計(jì)提供了互動(dòng)內(nèi)容,但是這種互動(dòng)性是完全建立在服務(wù)器之上的。這些文本會(huì)告訴CGI該做些什么。Perl是最常用的,因?yàn)樗O(shè)計(jì)的目的就是為了處理和解釋文本,所以不論服務(wù)器用的是那種處理器,或是那種操作系統(tǒng),都能安裝Perl。CGI程序的相應(yīng)時(shí)間取決于它要發(fā)送多少數(shù)據(jù),以及服務(wù)器端各Internet的負(fù)載。而且,毫無(wú)疑問(wèn)你肯定做過(guò)像填寫(xiě)表格這種簡(jiǎn)單的事。絕大多數(shù)運(yùn)行Web瀏覽器的機(jī)器都有強(qiáng)大的引擎,能作很多工作,而且在原告靜態(tài)的HTML方法下,大多數(shù)時(shí)間,它們都是在傻等著服務(wù)器發(fā)送下一個(gè)頁(yè)面。最后,你還得寫(xiě)程序,還要解決一串讓人眼花繚亂的問(wèn)題,還是提供客戶(hù)端編程的解決方案。它要求用戶(hù)從網(wǎng)上下載插件程序,然后把它集成到瀏覽器里。插件對(duì)于客戶(hù)端編程的價(jià)值在于,它能讓專(zhuān)家級(jí)的程序員開(kāi)發(fā)一種新的語(yǔ)言,并且不經(jīng)開(kāi)發(fā)商的同意,就把這種語(yǔ)言加進(jìn)瀏覽器里。腳本語(yǔ)言應(yīng)該比較簡(jiǎn)單,而且作為HTML頁(yè)面的一個(gè)部分,它們都是簡(jiǎn)單的文本,所以會(huì)隨頁(yè)面一起獲取,而且裝載也很快。然而,腳本語(yǔ)言也許能解決百分之十的客戶(hù)端編程的問(wèn)題。JavaScript可能是人氣最旺的。此外講JavaScript的書(shū)可能要比其它語(yǔ)言的都多,而且有些工具還能自動(dòng)生成包括JavaScript程序的