【正文】
ication [Sun, JBS]. Model 2: The release of the Servlet/JSP Specification described Model 2 as an architecture that uses servlets and JSP pages together in the same application. The term Model 2 disappeared from later releases, but it remains in popular use among Java web developers. Under Model 2, servlets handle the data access and navigational flow, while JSP pages handle the presentation. Model 2 lets Java engineers and HTML developers each work on their own part of the application. A change in one part of a Model 2 application does not mandate a change to another part of the application. HTML developers can often change the look and feel of an application without changing how the backoffice servlets work. The Struts framework is based on the Model 2 architecture. It provides a controller servlet to handle the navigational flow and special classes to help with the data access. A substantial custom tag library is bundled with the framework to make Struts easy to use 9 with JSP pages. Summary: In this article, we introduced Struts as an application framework. We examined the technology behind HTTP, the Common Gateway Interface, Java servlets, JSPs, and JavaBeans. We also looked at the Model 2 application architecture to see how it is used to bine servlets and JSPs in the same application. Now that you have had a taste of what it is like to develop a web application with Struts, in chapter 2 we dig deeper into the theory and practice behind the Struts architecture. xxx大學畢業(yè)設計(論文)外文翻譯 —— 譯文 1 JSP 應用框架 什么是應用框架: 框架( framework)是可重用的,半成品的應用程序,可以用來產(chǎn)生專門的定制程序。 mutators are used to change a JavaBean’s state. Mutators are always prefixed with lowercase token set followed by the property name. The first character in the property name must be uppercase. The return value is always void— mutators only change property values。 其它類型的框架: 框架的概念不僅用于應用程序也可用于組件。 使用的技術: 使用 Struts 的應用開 發(fā)使用了大量的其他基礎技術。Web應用程序就是使用 HTTP協(xié)議在運行瀏覽器的計算機和運行的服務器的程序間傳輸數(shù)據(jù)。沒有 大量的協(xié)商和連接持久性,無狀態(tài)協(xié)議可以處理大量的請求。 HTTP 請求頭跟在首行后面,可以沒有也可以有多個。服務器接受請求,發(fā)出響應,并且繼續(xù)愉快地處理文本請求。通常這里的文件使用Hypertext Markup Language (HTML) [W3C,HTML] 格式化,以使瀏覽器可以顯示它們。 CGI使用標準的操作系統(tǒng)特征,比如環(huán)境變量和標準輸入輸出,在 Web服務器間以及和主機系統(tǒng)間創(chuàng)建橋接和網(wǎng)關。 CGI程序的另一個缺點是平臺依賴性,一個平臺上開發(fā)的程序不一定在另一個平臺上能運行。為了使常規(guī) web servers 能訪問 servlet, servlet被安插在一個容器之中。 Servlet開發(fā) 人員可以使用 init() 方法保持對昂貴資源的引用,比如到數(shù)據(jù)庫或者 EJB Home接口的連接 ,以便它們可以在不同的請求之間進行共享。 在產(chǎn)生 HTTP響應的 Servlet 中是很普遍的。為將動態(tài)內(nèi)容引入頁面,開發(fā)人員可以將腳本元素置入頁面之中。重要的是記住, JSP頁面事實上是 一個 servlet。這些方法獲得一個 JspWriter 對象,你可以用它來輸出你需要的 HTML內(nèi)容。屬性名的第一個字母必須大寫。簡單屬性的 Accessor 在其方法體中不能接受參數(shù)。其他組件可以使用 Java 的反射 API 通過查找前綴為 set、 is或者 get的方法來發(fā)現(xiàn) JavaBean的屬性。 Model 2使 Java工程師和 HTML設計者分別工作于它 們所擅長和負責的部分。 我們也說明了 Model 2應用架構(gòu),以及它如何用來將 servlets 和 JSP 在結(jié)合在同一個應用之中。它提供一個控制器 servlet來處理導航流和一些特殊類來幫助數(shù)據(jù)訪問。一個頁面的動態(tài)數(shù)據(jù)可以使用一個 JavaBean來傳遞,并且 JSP 標記可以隨后使用 bean的屬性來定制頁面的輸出。屬性名的首字母必須大寫。例如,對 Double 類型的屬性 weight 的 mutator方法體可能是: public void setWeight(Double weight) 相似的設計模式也用于訪問器方法的創(chuàng)建。 4.這個語句導入將在本頁中使用的標簽庫,并分配給它一個前綴。要編寫 JavaBean,類必須是具體類和公共類,并且具有無參數(shù)的構(gòu)造器( NONARGS CONSTRUCTOR)。當一個客戶請求 JSP頁面時,容器將頁面翻譯成 Java servlet 源代碼文件,并將它編譯成 Java 類文件 —— 就象你寫的 servlet文件一樣。 它們喜歡 HTML設計人員處理表現(xiàn)層的工作,而 Java 工程師則專注于業(yè)務邏輯。 JavaServer Pages: 雖然 servlets 對 CGI 程序來說前進了一大步,但它也不是萬能靈藥。但和 CGI 程序不同,并不是針對每個請求都要創(chuàng)建一個新的 servlet。它接受請求并產(chǎn)生響應。 CGI定義了一套關于什么信息將作為環(huán)境變量傳遞,以及它希望怎樣使用標準輸入和輸出的慣例。 定義 靜態(tài)內(nèi)容直接來自于文本或數(shù)據(jù)文件,比如 HTML 或者 JPEG 文件。 URL重寫是在頁面地址中存儲一個特殊的標記, Java服務器可以用它來跟蹤用戶。 一旦服務器接收到請求,它就要產(chǎn)生一個 HTTP響應。這使應用程序很容易創(chuàng)建 HTTP請求。因為它們知道每一個連接的狀態(tài),以及每一個使用它的人。 超文本傳輸協(xié)議 (HTTP): 當兩個國家之間進行調(diào)解時,外交官們總是遵循一定的正式協(xié)議。某些框架被限制于專門的開發(fā)環(huán)境中。開發(fā)傳統(tǒng)桌面應用的開發(fā)人員更習慣于那些可以涵蓋應用開發(fā)同一性的工具包和開發(fā)環(huán)境。 外文翻譯原文及譯文 1 JSP application frameworks What are application frameworks: A framework is a reusable, semiplete application that can be specialized to produce custom applications [Johnson]. Like people, software applications are more alike than they are different. They run on the same puters, expect input from the same devices, output to the same displays, and save data to the same hard disks. Developers working on conventional desktop applications are accustomed to toolkits and development environments that leverage the sameness between applications. Application frameworks build on this mon ground to provide developers with a reusable structure that can serve as the foundation for their own products. A framework provides developers with a set of backbone ponents that have the following characteristics: are known to work well in other applications. 2. They are ready to use with the next project. 3. They can also be used by other teams in the organization. Frameworks are the classic buildversusbuy proposition. If you build it, you will understand it when you are done— but how long will it be before you can roll your own? If you buy it, you will have to climb the learning curve— and how long is that going to take? There is no right answer here, but most observers would agree that frameworks such as Struts provide a significant return