【正文】
Bean的相關(guān)內(nèi)容,當(dāng)然都是比較粗略的介紹其中的基本內(nèi)容,僅僅起到拋磚引玉的作用,如果讀者需要更詳細(xì)的信息,請(qǐng)參考相應(yīng)的JSP的書(shū)籍。 概述JSP(Java Server Pages)是由Sun Microsystems公司倡導(dǎo)、許多公司參與一起建立的一種動(dòng)態(tài)網(wǎng)頁(yè)技術(shù)標(biāo)準(zhǔn),其在動(dòng)態(tài)網(wǎng)頁(yè)的建設(shè)中有其強(qiáng)大而特別的功能。JSP與Microsoft的ASP技術(shù)非常相似。兩者都提供在HTML代碼中混合某種程序代碼、由語(yǔ)言引擎解釋執(zhí)行程序代碼的能力。下面我們簡(jiǎn)單的對(duì)它進(jìn)行介紹。JSP頁(yè)面最終會(huì)轉(zhuǎn)換成servlet。因而,從根本上,JSP頁(yè)面能夠執(zhí)行的任何任務(wù)都可以用servlet來(lái)完成。然而,這種底層的等同性并不意味著servlet和JSP頁(yè)面對(duì)于所有的情況都等同適用。問(wèn)題不在于技術(shù)的能力,而是二者在便利性、生產(chǎn)率和可維護(hù)性上的不同。畢竟,在特定平臺(tái)上能夠用Java編程語(yǔ)言完成的事情,同樣可以用匯編語(yǔ)言來(lái)完成,但是選擇哪種語(yǔ)言依舊十分重要。和單獨(dú)使用servlet相比,JSP提供下述好處:JSP中HTML的編寫(xiě)與維護(hù)更為簡(jiǎn)單。JSP中可以使用常規(guī)的HTML:沒(méi)有額外的反斜杠,沒(méi)有額外的雙引號(hào),也沒(méi)有暗含的Java語(yǔ)法。能夠使用標(biāo)準(zhǔn)的網(wǎng)站開(kāi)發(fā)工具。即使是那些對(duì)JSP一無(wú)所知的HTML工具,我們也可以使用,因?yàn)樗鼈儠?huì)忽略JSP標(biāo)簽(JSP tags)。可以對(duì)開(kāi)發(fā)團(tuán)隊(duì)進(jìn)行劃分。Java程序員可以致力于動(dòng)態(tài)代碼。Web開(kāi)發(fā)人員可以將經(jīng)理集中在表示層(presentation layer)上。對(duì)于大型的項(xiàng)目,這種劃分極為重要。依據(jù)開(kāi)發(fā)團(tuán)隊(duì)的大小,及項(xiàng)目的復(fù)雜程度,可以對(duì)靜態(tài)HTML和動(dòng)態(tài)內(nèi)容進(jìn)行弱分離(weaker separation)和強(qiáng)分離(stronger separation)。此處的討論并不是說(shuō)人們應(yīng)該放棄使用servlet而僅僅使用JSP。事實(shí)上,幾乎所有的項(xiàng)目都會(huì)同時(shí)用到這兩種技術(shù)。在某些項(xiàng)目中,更適宜選用servlet,而針對(duì)項(xiàng)目中的某些請(qǐng)求,我們可能會(huì)在MVC構(gòu)架下組合使用這兩項(xiàng)技術(shù)。我們總是希望用適當(dāng)?shù)墓ぞ咄瓿上鄬?duì)應(yīng)的工作,僅僅是servlet并不一定能夠勝任所有工作。 JSP的由來(lái)Sun公司的JSP技術(shù),使Web頁(yè)面開(kāi)發(fā)人員可以使用HTML或者XML標(biāo)識(shí)來(lái)設(shè)計(jì)和格式化最終頁(yè)面。使用JSP標(biāo)識(shí)或者小腳本來(lái)生成頁(yè)面上的動(dòng)態(tài)內(nèi)容(內(nèi)容是根據(jù)請(qǐng)求來(lái)變化的)。Java Servlet是JSP技術(shù)的基礎(chǔ),而且大型的Web應(yīng)用程序的開(kāi)發(fā)需要Java Servlet和JSP配合才能完成,Servlet這個(gè)名稱(chēng)源于Applet,現(xiàn)在國(guó)內(nèi)的翻譯方式很多,本書(shū)為了避免誤會(huì),決定直接采用Servlet而不做任何翻譯,讀者如果愿意,可以稱(chēng)之為“小服務(wù)程序”。Servlet其實(shí)和傳統(tǒng)的CGI、ISAPI、NSAPI等Web程序開(kāi)發(fā)工具的作用是相似的,在使用Java Servlet以后,用戶(hù)不必再使用效率低下的CGI方式,也不必使用只能在某個(gè)固定Web服務(wù)器平臺(tái)運(yùn)行的API方式來(lái)動(dòng)態(tài)生成Web頁(yè)面。許多Web服務(wù)器都支持Servlet,即使不直接支持Servlet的Web服務(wù)器也可以通過(guò)附加的應(yīng)用服務(wù)器和模塊來(lái)支持Servlet。得益于Java的跨平臺(tái)的特性,Servlet也是平臺(tái)無(wú)關(guān)的,實(shí)際上,只要符合Java Servlet規(guī)范,Servlet是完全與平臺(tái)無(wú)關(guān)且是與Web服務(wù)器無(wú)關(guān)的。由于Java Servlet內(nèi)部是以線(xiàn)程方式提供服務(wù),不必對(duì)于每個(gè)請(qǐng)求都啟動(dòng)一個(gè)進(jìn)程,并且利用多線(xiàn)程機(jī)制可以同時(shí)為多個(gè)請(qǐng)求服務(wù),因此Java Servlet效率非常高。但Java Servlet也不是沒(méi)有缺點(diǎn),和傳統(tǒng)的CGI、ISAPI、NSAPI方式相同,Java Servlet是利用輸出HTML語(yǔ)句來(lái)實(shí)現(xiàn)動(dòng)態(tài)網(wǎng)頁(yè)的,如果用Java Servlet來(lái)開(kāi)發(fā)整個(gè)網(wǎng)站,動(dòng)態(tài)部分和靜態(tài)頁(yè)面的整合過(guò)程會(huì)非常難以實(shí)現(xiàn)。為了解決Java Servlet的這種缺點(diǎn),SUN推出了JSP。許多年前,Marty受到邀請(qǐng), Gosling Java編程語(yǔ)言的發(fā)明者。隔幾個(gè)位置,是來(lái)自華盛頓一家大型軟件公司的高級(jí)經(jīng)理。在討論過(guò)程中,研討會(huì)的主席提出了Jini的議題,這在當(dāng)時(shí)是一項(xiàng)新的Java技術(shù)。,雖然現(xiàn)在言之過(guò)早,但這看起來(lái)會(huì)是非常有前途的一項(xiàng)技術(shù)。他們會(huì)持續(xù)關(guān)注這項(xiàng)技術(shù),如果這項(xiàng)技術(shù)變得流行起來(lái),他們會(huì)遵循公司的“接受并擴(kuò)充(embrace and extend)”, Gosling隨意地插話(huà)說(shuō)“你的意思其實(shí)就是不接受且不擴(kuò)充(disgrace and distend)?!痹诖? Gosling的抱怨顯示出,他感到這個(gè)公司會(huì)從其他公司那里拿走技術(shù),,形勢(shì)已經(jīng)完全不同。Java團(tuán)隊(duì)并沒(méi)有發(fā)明這一思想將頁(yè)面設(shè)計(jì)成由靜態(tài)HTML和用特殊標(biāo)簽標(biāo)記的動(dòng)態(tài)代碼混合組成.。ColdFusion多年前就已經(jīng)這樣做了。甚至ASP(來(lái)自于前述經(jīng)理所在公司的一項(xiàng)產(chǎn)品)都在JSP出現(xiàn)之前推廣了這種方式。實(shí)際上,JSP不只采用了這種通用概念,它甚至使用許多和ASP相同的特殊標(biāo)簽。JSP是建立在Java servlets模型之上的表達(dá)層技術(shù),它使編寫(xiě)HTML變得更簡(jiǎn)單。像SSJS一樣,它也允許你將靜態(tài)HTML內(nèi)容與服務(wù)器端腳本混合起來(lái)生成動(dòng)態(tài)輸出。JSP把Java作為默認(rèn)的腳本語(yǔ)言,然而,就像ASP可以使用其他語(yǔ)言(如JavaScript和VBScript)一樣,JSP規(guī)范也允許使用其他語(yǔ)言。附錄2 外文參考文獻(xiàn)(原文)THE TECHNIQUE DEVELOPMENT HISTORY OF JSPBy:Kathy Sierra and Bert BatesSource: Servletamp。JSPThe Java Server Pages( JSP) is a kind of according to web of the script plait distance technique, similar carries the script language of Java in the server of the Netscape pany of server side JavaScript( SSJS) and the Active Server Pages(ASP) of the Microsoft. JSP pares the SSJS and ASP to have better can expand sex, and it is no more exclusive than any factory or some one particular server of Web. Though the norm of JSP is to be draw up by the Sun pany of, any factory can carry out the JSP on own system. The After Sun release the JSP( the Java Server Pages) formally, the this kind of new Web application development technique very quickly caused the people39。s concern. JSP provided a special development environment for the Web application that establishes the high dynamic state. According to the Sun parlance, the JSP can adapt to include the Apache WebServer, on the market at inside of 85% server product.This chapter will introduce the related knowledge of JSP and Databases, and JavaBean related contents, is all certainly rougher introduction among them basic contents, say perhaps to is a Guide only, if the reader needs the more detailed information, pleasing the book of consult the homologous JSP. GENERALIZEThe JSP(Java Server Pages) is from the pany of Sun Microsystems initiate, the many panies the participate to the build up the together of the a kind the of dynamic the state web the page technique standard, the it have the it in the construction the of the dynamic state the web page the strong but the do not the especially of the function. JSP and the technique of ASP of the Microsoft is very alike. Both all provide the ability that mixes with a certain procedure code and is explain by the language engine to carry out the procedure code in the code of HTML. Underneath we are simple of carry on the introduction to it.JSP pages are translated into servlets. So, fundamentally, any task JSP pages can perform could also be acplished by servlets. However, this underlying equivalence does not mean that servlets and JSP pages are equally appropriate in all scenarios. The issue is not the power of the technology, it is the convenience, productivity, and maintainability of one or the other. After all, anything you can do on a particular puter platform in the Java programming language you could also do in assembly language. But it still matters which you choose.JSP provides the following benefits over servlets alone: ? It is easier to write and maintain the HTML. Your static code is ordinary HTML: no extra backslashes, no double quotes, and no lurking Java syntax. ? You can use standard Website development tools. Even HTML tools that know nothing about JSP can be used because they simply ignore the JSP tags. ? You can divide up your development team. The Java programmers can work on the dynamic code. The Web developers can concentrate on the presentation layer. On large projects, this division is very important. Depending on the size of your team and the plexity of your project, you can enforce a weaker or stronger separation between the static HTML and the dynamic content.Now, this discussion is not to say that you should stop using servlets and use only JSP instead. By no means. Almost all projects will use both. For some requests in your project, you will use servlets. For others, you will use JSP. For still others, you will bine them with the MVC architecture . You want the appropriate tool for the job, and servlets, by themselves, do not plete your toolkit. SOURCE OF