已閱讀5頁,還剩4頁未讀, 繼續(xù)免費閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領
文檔簡介
大連交通大學信息工程學院2011屆本科生畢業(yè)設計(論文)外文翻譯JSP Application FrameworksWhat are application frameworks:A framework is a reusable, semi-complete application that can be specialized toproduce custom applications Johnson. Like people, software applications are more alike than they are different. They run on the same computers, 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 common 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 components that have the following characteristics:1.They 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 build-versus-buy proposition. If you build it, you will understand it when you are donebut how long will it be before you can roll your own? If you buy it, you will have to climb the learning curveand 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 on investment compared to starting from scratch, especially for larger projects.Enabling technologies:Applications developed with Struts are based on a number of enabling technologies. These components are not specific to Struts and underlie every Java web application. A reason that developers use frameworks like Struts is to hide the nasty details behind acronyms like HTTP, CGI, and JSP. As a Struts developer, you dont need to be an alphabet soup guru, but a working knowledge of these base technologies can help you devise creative solutions to tricky problems.Java servlets:Suns Java Servlet platform directly addresses the two main drawbacks of CGI programs.First, servlets offer better performance and utilization of resources than conventional CGI programs. Second, the write-once, run-anywhere nature of Java means that servlets are portable between operating systems that have a Java Virtual Machine (JVM).A servlet looks and feels like a miniature web server. It receives a request and renders a response. But, unlike conventional web servers, the servlet application programming interface (API) is specifically designed to help Java developers create dynamic applications.The servlet itself is simply a Java class that has been compiled into byte code, like any other Java object. The servlet has access to a rich API of HTTP-specific services, but it is still just another Java object running in an application and can leverage all your other Java assets.To give conventional web servers access to servlets, the servlets are plugged into containers. The servlet container is attached to the web server. Each servlet can declare what URL patterns it would like to handle. When a request matching a registered pattern arrives, the web server passes the request to the container, and the container invokes the servlet.But unlike CGI programs, a new servlet is not created for each request. Once the container instantiates the servlet, it will just create a new thread for each request. Java threads are much less expensive than the server processes used by CGI programs. Once the servlet has been created, using it for additional requests incurs very little overhead. Servlet developers can use the init() method to hold references to expensive resources, such as database connections or EJB Home Interfaces, so that they can be shared between requests. Acquiring resources like these can take several secondswhich is longer than many surfers are willing to wait. The other edge of the sword is that, since servlets are multithreaded, servlet developers must take special care to be sure their servlets are thread-safe. To learn more about servlet programming, we recommend Java Servlets by Example, by Alan R. Williamson Williamson. The definitive source for Servlet information is the Java Servlet Specification Sun, JST.JavaServer Pages:While Java servlets are a big step up from CGI programs, they are not a panacea. To generate the response, developers are still stuck with using println statements to render the HTML. Code that looks like:out.println(One line of HTML.);out.println(Another line of HTML.);is all too common in servlets that generate the HTTP response. There are libraries that can help you generate HTML, but as applications grow more complex, Java developers end up being cast into the role of HTML page designers.Meanwhile, given the choice, most project managers prefer to divide development teams into specialized groups. They like HTML designers to be working on the presentation while Java engineers sweat the business logic. Using servlets alone encourages mixing markup with business logic, making it difficult for team members to specialize.To solve this problem, Sun turned to the idea of using server pages to combine scripting and templating technologies into a single component. To build Java Server Pages, developers start by creating HTML pages in the same old way, using the same old HTML syntax. To bring dynamic content into the page, the developer can also place JSP scripting elements on the page. Scripting elements are tags that encapsulate logic that is recognized by the JSP. You can easily pick out scripting elements on JSP pages by looking for code that begins with .To be seen as a JSP page, the file just needs to be saved with an extension of .jsp.When a client requests the JSP page, the container translates the page into a source code file for a Java servlet and compiles the source into a Java class filejust as you would do if you were writing a servlet from scratch. At runtime, the container can also check the last modified date of the JSP file against the class file. If the JSP file has changed since it was last compiled, the container will retranslate and rebuild the page all over again.Project managers can now assign the presentation layer to HTML developers, who then pass on their work to Java developers to complete the business-logic portion. The important thing to remember is that a JSP page is really just a servlet. Anything you can do with a servlet, you can do with a JSP.JavaBeans:JavaBeans are Java classes which conform to a set of design patterns that make them easier to use with development tools and other components.DEFINITION A JavaBean is a reusable software component written in Java. To qualify as a JavaBean, the class must be concrete and public, and have a noargument constructor. JavaBeans expose internal fields as properties by providing public methods that follow a consistent design pattern. Knowing that the property names follow this pattern, other Java classes are able to use introspection to discover and manipulate JavaBean properties. The JavaBean design patterns provide access to the beans internal state through two flavors of methods: accessors are used to read a JavaBeans state; mutators are used to change a JavaBeans 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 voidmutators only change property values; they do not retrieve them. The mutator for a simple property takes only one parameter in its signature, which can be of any type. Mutators are often nicknamed setters after their prefix. The mutator method signature for a weight property of the type Double would be:public void setWeight(Double weight)A similar design pattern is used to create the accessor method signature. Accessor methods are always prefixed with the lowercase token get, followed by the property name. The first character in the property name must be uppercase. The return value will match the method parameter in the corresponding mutator. Accessors for simple properties cannot accept parameters in their method signature. Not surprisingly, accessors are often called getters.The accessor method signature for our weight property is:public Double getWeight()If the accessor returns a logical value, there is a variant pattern. Instead of using the lowercase token get, a logical property can use the prefix is, followed by the property name. The first character in the property name must be uppercase. The return value will always be a logical valueeither boolean or Boolean. Logical accessors cannot accept parameters in their method signature.The boolean accessor method signature for an on property would bepublic boolean isOn()The canonical method signatures play an important role when working with Java- Beans. Other components are able to use the Java Reflection API to discover a JavaBeans properties by looking for methods prefixed by set, is, or get. If a component finds such a signature on a JavaBean, it knows that the method can be used to access or change the beans properties.Sun introduced JavaBeans to work with GUI components, but they are now used with every aspect of Java development, including web applications. When Sun engineers developed the JSP tag extension classes, they designed them to work with JavaBeans. The dynamic data for a page can be passed as a JavaBean, and the JSP tag can then use the beans properties to customize the output.For more on JavaBeans, we highly recommend The Awesome Power of JavaBeans, by Lawrence H. Rodrigues Rodrigues. The definitive source for JavaBean information is the JavaBean Specification Sun, JBS.Model 2:The 0.92 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 back-office 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 with JSP pages.JSP應用框架什么是應用框架:框架(framework)是可重用的,半成品的應用程序,可以用來產(chǎn)生專門的定制程序。象人一樣,軟件應用的相似性比不同點要多。它們運行在相似的機器上,期望從相同的設備輸入信息,輸出到相同的顯示設備,并且將數(shù)據(jù)存儲到相同的硬盤設備。開發(fā)傳統(tǒng)桌面應用的開發(fā)人員更習慣于那些可以涵蓋應用開發(fā)同一性的工具包和開發(fā)環(huán)境。構(gòu)架在這些公共基礎上的應用框架可以為開發(fā)人員提供可以為他們的產(chǎn)品提供可重用服務的基礎架構(gòu)??蚣芟蜷_發(fā)人員提供一系列具有以下特征的骨架組件:1已經(jīng)知道它們在其它程序上工作得很好;2它們隨時可以在下一個項目中使用;3它們可以被組織的其它團隊使用;對于框架是典型的構(gòu)建還是購買命題。如果你自己構(gòu)建它,在你完成時你就會理解它,但是在你被融入之前又將花費多長時間呢?如果要購買,你必須得克服學習曲線,同樣,在你可以用它進行工作之前又得花多長時間?這里沒有所謂正確答案,但許多觀察者都會同意,象Struts這樣的框架能提供比從頭開始開發(fā)更顯著的投資回報,特別是對于大型項目來說。使用的技術:使用Struts的應用開發(fā)使用了大量的其他基礎技術。這些技術并不是專門針對Struts,而是所有Java web 應用都可以使用的。開發(fā)者使用Struts之類的框架是為了隱藏在諸如HTTP,CGI,以及JSP之類技術后面的繁瑣的細節(jié)。作為一個Struts開發(fā)者,你并不需要知曉所有的相關知識,但是這些基本技術的工作原理可能有助于你針對棘手問題設計出創(chuàng)造性的方案。Java servlet:Sun公司的Java Servlet平臺直接解決了CGI程序的兩個主要缺點:首先,servlet 比常規(guī)CGI 程序提供更好的性能和資源利用。其次,一次編寫,隨處運行的JAVA特性意味著servlet在有JVM 的操作系統(tǒng)間是輕便的可移動的。Servlet看起來好像是一個微小的web server。它接受請求并產(chǎn)生響應。但,和常規(guī)web server不同,servlet API 是專門設計來幫助Java 開發(fā)人員創(chuàng)建動態(tài)應用的。Servlet 本身是要編譯成字節(jié)碼的Java類,就像其他Java對象一樣。Servlet訪問HTTP 特定服務的API,但它仍然是一個運行于程序之中的Java 對象,并可以利用所有的Java 資產(chǎn)。為了使常規(guī)web servers能訪問servlet,servlet被安插在一個容器之中。Servlet容器連接到Web服務器。每servlet 都可以聲明它可以處理何種樣式的URL。當符合所注冊樣式的請求到達,web server將請求傳遞給容器,容器則調(diào)用響應的servlet。但和CGI 程序不同,并不是針對每個請求都要創(chuàng)建一個新的servlet。一旦容器實例化了一個servlet,它就僅為每個新的請求創(chuàng)建一個新的線程。Java線程可比使用CGI程序的服務器處理開銷小多了。一旦servlet被創(chuàng)建,使用它處理額外的請求僅帶來很小的額外開銷。Servlet開發(fā)人員可以使用init() 方法保持對昂貴資源的引用,比如到數(shù)據(jù)庫或者EJB Home接口的連接,以便它們可以在不同的請求之間進行共享。獲得這些資源要耗費數(shù)秒時間,這比大多數(shù)沖浪者愿意等的時間要長些。Servlet的另一個好處是,它是多線程的,servlet開發(fā)人員必須特別注意確保它們的servlet是線程安全的。學習servlet 編程,我們推薦Java Servlets by Example, 作者Alan R. WilliamsonWilliamson。JavaServer Pages:雖然servlets對CGI程序來說前進了一大步,但它也不是萬能靈藥。為了產(chǎn)生響應,開發(fā)人員不得不使用大量的println語句來生成HTML。比如這樣的代碼:out.println(One line of HTML.);out.println(Another line of HTML.);在產(chǎn)生HTTP響應的Servlet 中是很普遍的。也有一些庫有助于你產(chǎn)生HTML。隨著應用越來越復雜,Java開發(fā)人員將不再扮演HTML頁面設計的角色。同時,大多數(shù)項目經(jīng)理更喜歡將團隊分成不同的小組。 它們喜歡HTML設計人員處理表現(xiàn)層的工作,而Java工程師則專注于業(yè)務邏輯。單獨使用servlet的做法鼓勵混合標記和業(yè)務邏輯,很難區(qū)分團隊人員的專業(yè)工作。為解決這個問題,Sun提出了一個將腳本和模板技術結(jié)合到一個組件中的服務器頁面技術(JavaServer Pages)。為創(chuàng)建JSP頁面, 開發(fā)者按創(chuàng)建HTML頁面類似的方式創(chuàng)建頁面,使用相同的HTML 語法。為將動態(tài)內(nèi)容引入頁面,開發(fā)人員可以將腳本元素置入頁面之中。腳本元素是一些標記,封裝了可以被JSP識別的邏輯。你可以在JSP頁面中很容易的識別出腳本元素,他們被封裝在一對標記中。為了識別JSP頁面,文件需要保存為擴展名.jsp。當一個客戶請求JSP頁面時,容器將頁面翻譯成Java servlet 源代碼文件,并將它編譯成Java 類文件就象你寫的servlet文件一樣。在運行時,容器也能檢測JSP文件和相應的類的最后更新時間。如果,JSP 文件自上次編譯以來被修改了,容器將重新翻譯和編譯JSP文件。項目經(jīng)理現(xiàn)在可以將表現(xiàn)層分派給HTML 開發(fā)人員,將業(yè)務邏輯工作分派給JAVA開發(fā)人員。重要的是記住,JSP頁面事實上是一個servlet。你可以在servlet做的,也可以在JSP中做。JavaBean:JavaBean是一種 Java類,它遵從一定的設計模式,使它們易于和其他開發(fā)工具和組件一起使用。定義 JavaBean 是一種JAVA 語言寫成的可重用組件。要編寫JavaBean,類必須是具體類和公共類,并且具有無參數(shù)的構(gòu)造器(NON-ARGS CONSTRUCTOR)。JavaBean通過提供符合一致性設計模式的公共訪問方法將內(nèi)部字段暴露稱為屬性。眾所周知,屬性名稱也符合這種模式,其他JAVA 類可以通過自省機制發(fā)現(xiàn)和操作這些JavaBean 屬性。我們必須做的如下:1編寫一個類,通過實現(xiàn)doStart()或者doEnd()方法來實現(xiàn)javax.servlet.jsp.tagext.TagSupport 或者javax.servlet.jsp.tagext.BodyTagSupport接口。這些方法獲得一個JspWriter對象,你可以
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二氧化碳樹脂裝置操作工崗前復測考核試卷含答案
- 海南農(nóng)墾投資控股集團招聘面試題及答案
- 船舶電子技工崗前規(guī)程考核試卷含答案
- 家用電冰箱制造工崗前實操綜合知識考核試卷含答案
- 廣東機場管理集團招聘面試題及答案
- 無人機行業(yè)規(guī)范自律承諾書(7篇)
- 造林更新工安全知識宣貫水平考核試卷含答案
- 房地產(chǎn)經(jīng)紀人招聘試題及答案
- 熱風爐工沖突解決競賽考核試卷含答案
- 染化料配制操作工安全管理模擬考核試卷含答案
- 2025年淮北市相山區(qū)公開招考村(社區(qū))后備干部66名筆試考試參考試題及答案解析
- 2025年貴州錦麟化工有限責任公司招聘備考題庫及一套參考答案詳解
- 2025年石家莊市公安局鹿泉分局公開招聘留置看護警務輔助人員30人的備考題庫有答案詳解
- 【數(shù) 學】2025-2026學年北師大版七年級數(shù)學上冊期末綜合提升卷III
- 2025年甘肅省書記員考試試題及答案
- 【MOOC】3D工程圖學-華中科技大學 中國大學慕課MOOC答案
- 模具定期保養(yǎng)點檢表
- 電工基礎(第六版)課后習題答案
- 快消品年度工作計劃
- 醫(yī)院后勤設備安全運維管理
- 思想道德與法治課件:第六章 第四節(jié) 自覺尊法學法守法用法
評論
0/150
提交評論