【正文】
Bean的相關(guān)內(nèi)容,當(dāng)然都是比較粗略的介紹其中的基本內(nèi)容,僅僅起到拋磚引玉的作用,如果讀者需要更詳細的信息,請參考相應(yīng)的JSP的書籍。 概述JSP(Java Server Pages)是由Sun Microsystems公司倡導(dǎo)、許多公司參與一起建立的一種動態(tài)網(wǎng)頁技術(shù)標(biāo)準(zhǔn),其在動態(tài)網(wǎng)頁的建設(shè)中有其強大而特別的功能。JSP與Microsoft的ASP技術(shù)非常相似。兩者都提供在HTML代碼中混合某種程序代碼、由語言引擎解釋執(zhí)行程序代碼的能力。下面我們簡單的對它進行介紹。JSP頁面最終會轉(zhuǎn)換成servlet。因而,從根本上,JSP頁面能夠執(zhí)行的任何任務(wù)都可以用servlet來完成。然而,這種底層的等同性并不意味著servlet和JSP頁面對于所有的情況都等同適用。問題不在于技術(shù)的能力,而是二者在便利性、生產(chǎn)率和可維護性上的不同。畢竟,在特定平臺上能夠用Java編程語言完成的事情,同樣可以用匯編語言來完成,但是選擇哪種語言依舊十分重要。和單獨使用servlet相比,JSP提供下述好處:JSP中HTML的編寫與維護更為簡單。JSP中可以使用常規(guī)的HTML:沒有額外的反斜杠,沒有額外的雙引號,也沒有暗含的Java語法。能夠使用標(biāo)準(zhǔn)的網(wǎng)站開發(fā)工具。即使是那些對JSP一無所知的HTML工具,我們也可以使用,因為它們會忽略JSP標(biāo)簽(JSP tags)。可以對開發(fā)團隊進行劃分。Java程序員可以致力于動態(tài)代碼。Web開發(fā)人員可以將經(jīng)理集中在表示層(presentation layer)上。對于大型的項目,這種劃分極為重要。依據(jù)開發(fā)團隊的大小,及項目的復(fù)雜程度,可以對靜態(tài)HTML和動態(tài)內(nèi)容進行弱分離(weaker separation)和強分離(stronger separation)。此處的討論并不是說人們應(yīng)該放棄使用servlet而僅僅使用JSP。事實上,幾乎所有的項目都會同時用到這兩種技術(shù)。在某些項目中,更適宜選用servlet,而針對項目中的某些請求,我們可能會在MVC構(gòu)架下組合使用這兩項技術(shù)。我們總是希望用適當(dāng)?shù)墓ぞ咄瓿上鄬?yīng)的工作,僅僅是servlet并不一定能夠勝任所有工作。 JSP的由來Sun公司的JSP技術(shù),使Web頁面開發(fā)人員可以使用HTML或者XML標(biāo)識來設(shè)計和格式化最終頁面。使用JSP標(biāo)識或者小腳本來生成頁面上的動態(tài)內(nèi)容(內(nèi)容是根據(jù)請求來變化的)。Java Servlet是JSP技術(shù)的基礎(chǔ),而且大型的Web應(yīng)用程序的開發(fā)需要Java Servlet和JSP配合才能完成,Servlet這個名稱源于Applet,現(xiàn)在國內(nèi)的翻譯方式很多,本書為了避免誤會,決定直接采用Servlet而不做任何翻譯,讀者如果愿意,可以稱之為“小服務(wù)程序”。Servlet其實和傳統(tǒng)的CGI、ISAPI、NSAPI等Web程序開發(fā)工具的作用是相似的,在使用Java Servlet以后,用戶不必再使用效率低下的CGI方式,也不必使用只能在某個固定Web服務(wù)器平臺運行的API方式來動態(tài)生成Web頁面。許多Web服務(wù)器都支持Servlet,即使不直接支持Servlet的Web服務(wù)器也可以通過附加的應(yīng)用服務(wù)器和模塊來支持Servlet。得益于Java的跨平臺的特性,Servlet也是平臺無關(guān)的,實際上,只要符合Java Servlet規(guī)范,Servlet是完全與平臺無關(guān)且是與Web服務(wù)器無關(guān)的。由于Java Servlet內(nèi)部是以線程方式提供服務(wù),不必對于每個請求都啟動一個進程,并且利用多線程機制可以同時為多個請求服務(wù),因此Java Servlet效率非常高。但Java Servlet也不是沒有缺點,和傳統(tǒng)的CGI、ISAPI、NSAPI方式相同,Java Servlet是利用輸出HTML語句來實現(xiàn)動態(tài)網(wǎng)頁的,如果用Java Servlet來開發(fā)整個網(wǎng)站,動態(tài)部分和靜態(tài)頁面的整合過程會非常難以實現(xiàn)。為了解決Java Servlet的這種缺點,SUN推出了JSP。許多年前,Marty受到邀請, Gosling Java編程語言的發(fā)明者。隔幾個位置,是來自華盛頓一家大型軟件公司的高級經(jīng)理。在討論過程中,研討會的主席提出了Jini的議題,這在當(dāng)時是一項新的Java技術(shù)。,雖然現(xiàn)在言之過早,但這看起來會是非常有前途的一項技術(shù)。他們會持續(xù)關(guān)注這項技術(shù),如果這項技術(shù)變得流行起來,他們會遵循公司的“接受并擴充(embrace and extend)”, Gosling隨意地插話說“你的意思其實就是不接受且不擴充(disgrace and distend)?!痹诖? Gosling的抱怨顯示出,他感到這個公司會從其他公司那里拿走技術(shù),,形勢已經(jīng)完全不同。Java團隊并沒有發(fā)明這一思想將頁面設(shè)計成由靜態(tài)HTML和用特殊標(biāo)簽標(biāo)記的動態(tài)代碼混合組成.。ColdFusion多年前就已經(jīng)這樣做了。甚至ASP(來自于前述經(jīng)理所在公司的一項產(chǎn)品)都在JSP出現(xiàn)之前推廣了這種方式。實際上,JSP不只采用了這種通用概念,它甚至使用許多和ASP相同的特殊標(biāo)簽。JSP是建立在Java servlets模型之上的表達層技術(shù),它使編寫HTML變得更簡單。像SSJS一樣,它也允許你將靜態(tài)HTML內(nèi)容與服務(wù)器端腳本混合起來生成動態(tài)輸出。JSP把Java作為默認(rèn)的腳本語言,然而,就像ASP可以使用其他語言(如JavaScript和VBScript)一樣,JSP規(guī)范也允許使用其他語言。附錄2 外文參考文獻(原文)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