【正文】
的模型為基礎,提供大量標簽和一個腳本平臺用來在HTML頁中顯示由JavaBeans產生或回送的內容。現在來看看JSP是如何處理HTTP請求的。另外,更加復雜的請求模型可看作從被請求頁呼叫其他JSP頁或JavaServlets。因為Servlet是編譯過的,所以網頁中的JSP代碼不需要在每次請求該頁時被解釋一遍。首先,在速度上,傳統的CGI程序需要使用系統的標準輸入輸出設備來實現動態(tài)網頁的生成,而JSP是直接和服務器相關聯的。其次,JSP是專門為Web開發(fā)而設計的,其目的是為了建立基于Web的應用程序,包含了一整套的規(guī)范和工具。由于是JSP引擎自動生成并編譯Servlet,不用程序員動手編譯代碼,所以JSP能帶給你高效的性能和快速開發(fā)所需的靈活性。這些代碼塊被JSP引擎組織到用戶看不到的Java Servlet中去,然后Servlet自動把它們編譯成Java字節(jié)碼。JSP代碼控制著進行邏輯處理時與JavaBeans組件的交互,并在動態(tài)生成的、混合了靜態(tài)HTML代碼的HTML頁中顯示結果。非Java開發(fā)者可以通過JSP 的標簽(Tags)來使用高級Java開發(fā)者創(chuàng)建的JavaBeans。這些技術使某領域內的專家可以為本領域內的垂直應用編寫組件,而開發(fā)者可以直接拿來使用而不必掌握這一領域的專門技術。HTML和圖形設計師把它們的設計的實施工作交給了Web編寫者,使他們不得不加倍工作——常常是手工編寫,因為沒有合適的工具可以把服務器端腳本與HTML內容結合起來。然而,隨著時間的推移,人們認識到這種方法不適于構建大型的、可升級的Web應用程序。按照JSP規(guī)范書寫,和Java沒有任何關系的Scriptlet也是可以的,不過,由于JSP的強大功能主要在于能和JavaBeans、Enterprise JavaBeans一起工作,所以即使是Scriptlet部分不使用Java,編譯成的執(zhí)行代碼也應該是與Java相關的。一般來說,在實際的JSP引擎中,JSP頁面在執(zhí)行時是編譯式,而不是解釋式的。作為一種基于文本的、以顯示為中心的開發(fā)技術,JSP提供了Java Servlet的所有好處,并且,當與一個JavaBeans類結合在一起時,提供了一種使內容和顯示邏輯分開的簡單方式。像SSJS一樣,它也允許你將靜態(tài)HTML 內容與服務器端腳本混合起來生成動態(tài)輸出。ColdFusion多年前就已經這樣做了。隔幾個位置,是來自華盛頓一家大型軟件公司的高級經理。由于Java Servlet 內部是以線程方式提供服務,不必對于每個請求都啟動一個進程,并且利用多線程機制可以同時為多個請求服務,因此Java Servlet效率非常高。Java Servlet是JSP技術的基礎,而且大型的Web應用程序的開發(fā)需要JavaServlet和JSP配合才能完成,Servlet這個名稱源于Applet,現在國內的翻譯方式很多,本書為了避免誤會,決定直接采用Servlet而不做任何翻譯,讀者如果愿意,可以稱之為“小服務程序”。針對項目中的某些請求,您可能會在MVC構架下組合使用這兩項技術。對于大型的項目,這種劃分極為重要。即使對那些對JSP一無所知的HTML工具,我們也可以使用,因為它們會忽略JSP標簽JSP tags。畢竟,在特定平臺上能夠用Java編程語言完成的事情,同樣可以用匯編語言來完成,但是選擇哪種語言依舊十分重要。JSP 頁面最終會轉換成servler。A. 概述JSP(Java Server Pages)是由Sun Microsystems公司倡導、許多公司參與一起建立的一種動態(tài)網頁技術標準,其在動態(tài)網頁的建設中有其強大而特別的功能。在Sun 正式發(fā)布JSP(Java Server Pages)之后,這種新的Web 應用開發(fā)技術很快引起了人們的關注。s machine/server the realm. JavaBeans and ActiveX were published the pany to expand to apply the procedure developer for Java and Windows to use to e to develop the plicated procedure quickly by the fast application procedure development( RAD) tool. These techniques make the expert in the some realm be able to write the module for the perpendicular application plait in the skill area, but the developer can go fetch the usage directly butneed not control the expertise of this realm.Be a kind of take module as the central development terrace, the JSP appeared. It with the JavaBeans and Enterprise JavaBeans(EJB) module includes the model of the business and the data logic for foundation, provide a great deal of label and a script terraces to use to e to show in the HTML page from the contents of JavaBeans creation or send a presentin return. Because of the property that regards the module as the center of the JSP, it can drive Java and not the developer of Java uses equally. Not the developer of Java can pass the JSP label( Tags) to use the JavaBeans that the deluxe developer of Java establish. The developer of Java not only can establish and use the JavaBeans, but also can use the language of Java to e to control more accurately in the JSP page according to the expression logic of the first floor JavaBeans.See now how JSP is handle claim of HTTP. In basic claim model, a claim directly was send to JSP page in. The code of JSP controls to carry on hour of the logic processing and module of JavaBeanses39。t do any translation, if reader would like to, can call it as small service procedure. The Servlet is similar to traditional CGI, ISAPI, NSAPI etc. Web procedure development the function of the tool in fact, at use the Java Servlet hereafter, the customer need not use again the lowly method of CGI of efficiency, also need not use only the ability e to born page of Web of dynamic state in the method of API that a certain fixed Web server terrace circulate. Many servers of Web all support the Servlet, even not support the Servlet server of Web directly and can also pass the additional applied server and the mold pieces to support the Servlet. Receive benefit in the characteristic of the Java crossplatform, the Servlet is also a terrace irrelevant, actually, as long as match the norm of Java Servlet, the Servlet is plete to have nothing to do with terrace and is to have nothing to do with server of Web. Because the Java Servlet is internal to provide the service by the line distance, need not start a progress to the each claimses, and make use of the multithreading mechanism can at the same time for several claim service, therefore the efficiency of Java Servlet is very high. But the Java Servle