




已閱讀5頁,還剩4頁未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
大連交通大學(xué)信息工程學(xué)院2011屆本科生畢業(yè)設(shè)計(論文)外文翻譯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應(yīng)用框架什么是應(yīng)用框架:框架(framework)是可重用的,半成品的應(yīng)用程序,可以用來產(chǎn)生專門的定制程序。象人一樣,軟件應(yīng)用的相似性比不同點(diǎn)要多。它們運(yùn)行在相似的機(jī)器上,期望從相同的設(shè)備輸入信息,輸出到相同的顯示設(shè)備,并且將數(shù)據(jù)存儲到相同的硬盤設(shè)備。開發(fā)傳統(tǒng)桌面應(yīng)用的開發(fā)人員更習(xí)慣于那些可以涵蓋應(yīng)用開發(fā)同一性的工具包和開發(fā)環(huán)境。構(gòu)架在這些公共基礎(chǔ)上的應(yīng)用框架可以為開發(fā)人員提供可以為他們的產(chǎn)品提供可重用服務(wù)的基礎(chǔ)架構(gòu)。框架向開發(fā)人員提供一系列具有以下特征的骨架組件:1已經(jīng)知道它們在其它程序上工作得很好;2它們隨時可以在下一個項(xiàng)目中使用;3它們可以被組織的其它團(tuán)隊(duì)使用;對于框架是典型的構(gòu)建還是購買命題。如果你自己構(gòu)建它,在你完成時你就會理解它,但是在你被融入之前又將花費(fèi)多長時間呢?如果要購買,你必須得克服學(xué)習(xí)曲線,同樣,在你可以用它進(jìn)行工作之前又得花多長時間?這里沒有所謂正確答案,但許多觀察者都會同意,象Struts這樣的框架能提供比從頭開始開發(fā)更顯著的投資回報,特別是對于大型項(xiàng)目來說。使用的技術(shù):使用Struts的應(yīng)用開發(fā)使用了大量的其他基礎(chǔ)技術(shù)。這些技術(shù)并不是專門針對Struts,而是所有Java web 應(yīng)用都可以使用的。開發(fā)者使用Struts之類的框架是為了隱藏在諸如HTTP,CGI,以及JSP之類技術(shù)后面的繁瑣的細(xì)節(jié)。作為一個Struts開發(fā)者,你并不需要知曉所有的相關(guān)知識,但是這些基本技術(shù)的工作原理可能有助于你針對棘手問題設(shè)計出創(chuàng)造性的方案。Java servlet:Sun公司的Java Servlet平臺直接解決了CGI程序的兩個主要缺點(diǎn):首先,servlet 比常規(guī)CGI 程序提供更好的性能和資源利用。其次,一次編寫,隨處運(yùn)行的JAVA特性意味著servlet在有JVM 的操作系統(tǒng)間是輕便的可移動的。Servlet看起來好像是一個微小的web server。它接受請求并產(chǎn)生響應(yīng)。但,和常規(guī)web server不同,servlet API 是專門設(shè)計來幫助Java 開發(fā)人員創(chuàng)建動態(tài)應(yīng)用的。Servlet 本身是要編譯成字節(jié)碼的Java類,就像其他Java對象一樣。Servlet訪問HTTP 特定服務(wù)的API,但它仍然是一個運(yùn)行于程序之中的Java 對象,并可以利用所有的Java 資產(chǎn)。為了使常規(guī)web servers能訪問servlet,servlet被安插在一個容器之中。Servlet容器連接到Web服務(wù)器。每servlet 都可以聲明它可以處理何種樣式的URL。當(dāng)符合所注冊樣式的請求到達(dá),web server將請求傳遞給容器,容器則調(diào)用響應(yīng)的servlet。但和CGI 程序不同,并不是針對每個請求都要創(chuàng)建一個新的servlet。一旦容器實(shí)例化了一個servlet,它就僅為每個新的請求創(chuàng)建一個新的線程。Java線程可比使用CGI程序的服務(wù)器處理開銷小多了。一旦servlet被創(chuàng)建,使用它處理額外的請求僅帶來很小的額外開銷。Servlet開發(fā)人員可以使用init() 方法保持對昂貴資源的引用,比如到數(shù)據(jù)庫或者EJB Home接口的連接,以便它們可以在不同的請求之間進(jìn)行共享。獲得這些資源要耗費(fèi)數(shù)秒時間,這比大多數(shù)沖浪者愿意等的時間要長些。Servlet的另一個好處是,它是多線程的,servlet開發(fā)人員必須特別注意確保它們的servlet是線程安全的。學(xué)習(xí)servlet 編程,我們推薦Java Servlets by Example, 作者Alan R. WilliamsonWilliamson。JavaServer Pages:雖然servlets對CGI程序來說前進(jìn)了一大步,但它也不是萬能靈藥。為了產(chǎn)生響應(yīng),開發(fā)人員不得不使用大量的println語句來生成HTML。比如這樣的代碼:out.println(One line of HTML.);out.println(Another line of HTML.);在產(chǎn)生HTTP響應(yīng)的Servlet 中是很普遍的。也有一些庫有助于你產(chǎn)生HTML。隨著應(yīng)用越來越復(fù)雜,Java開發(fā)人員將不再扮演HTML頁面設(shè)計的角色。同時,大多數(shù)項(xiàng)目經(jīng)理更喜歡將團(tuán)隊(duì)分成不同的小組。 它們喜歡HTML設(shè)計人員處理表現(xiàn)層的工作,而Java工程師則專注于業(yè)務(wù)邏輯。單獨(dú)使用servlet的做法鼓勵混合標(biāo)記和業(yè)務(wù)邏輯,很難區(qū)分團(tuán)隊(duì)人員的專業(yè)工作。為解決這個問題,Sun提出了一個將腳本和模板技術(shù)結(jié)合到一個組件中的服務(wù)器頁面技術(shù)(JavaServer Pages)。為創(chuàng)建JSP頁面, 開發(fā)者按創(chuàng)建HTML頁面類似的方式創(chuàng)建頁面,使用相同的HTML 語法。為將動態(tài)內(nèi)容引入頁面,開發(fā)人員可以將腳本元素置入頁面之中。腳本元素是一些標(biāo)記,封裝了可以被JSP識別的邏輯。你可以在JSP頁面中很容易的識別出腳本元素,他們被封裝在一對標(biāo)記中。為了識別JSP頁面,文件需要保存為擴(kuò)展名.jsp。當(dāng)一個客戶請求JSP頁面時,容器將頁面翻譯成Java servlet 源代碼文件,并將它編譯成Java 類文件就象你寫的servlet文件一樣。在運(yùn)行時,容器也能檢測JSP文件和相應(yīng)的類的最后更新時間。如果,JSP 文件自上次編譯以來被修改了,容器將重新翻譯和編譯JSP文件。項(xiàng)目經(jīng)理現(xiàn)在可以將表現(xiàn)層分派給HTML 開發(fā)人員,將業(yè)務(wù)邏輯工作分派給JAVA開發(fā)人員。重要的是記住,JSP頁面事實(shí)上是一個servlet。你可以在servlet做的,也可以在JSP中做。JavaBean:JavaBean是一種 Java類,它遵從一定的設(shè)計模式,使它們易于和其他開發(fā)工具和組件一起使用。定義 JavaBean 是一種JAVA 語言寫成的可重用組件。要編寫JavaBean,類必須是具體類和公共類,并且具有無參數(shù)的構(gòu)造器(NON-ARGS CONSTRUCTOR)。JavaBean通過提供符合一致性設(shè)計模式的公共訪問方法將內(nèi)部字段暴露稱為屬性。眾所周知,屬性名稱也符合這種模式,其他JAVA 類可以通過自省機(jī)制發(fā)現(xiàn)和操作這些JavaBean 屬性。我們必須做的如下:1編寫一個類,通過實(shí)現(xiàn)doStart()或者doEnd()方法來實(shí)現(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)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- MY銀行供應(yīng)鏈金融保理業(yè)務(wù)流程優(yōu)化研究
- 全GFRP筋增強(qiáng)混凝土剪力墻抗震性能研究
- 故事力法則下鄉(xiāng)村文旅景觀規(guī)劃設(shè)計研究-以浙江新昌縣棠村村為例
- 環(huán)境安全健康之間關(guān)系
- 護(hù)理質(zhì)量管理人員培訓(xùn)大綱
- 肺炎性心臟病護(hù)理
- 甲狀腺結(jié)節(jié)健康教育及指導(dǎo)
- 在線教育社群運(yùn)營策劃方案
- 護(hù)理心臟驟停的急救與后續(xù)管理
- 結(jié)腸腫瘤科普
- 2022-2023學(xué)年北京市東城區(qū)高二(下)期末化學(xué)試卷(含解析)
- 防溺水老師培訓(xùn)課件
- 《植物生長與環(huán)境》課程標(biāo)準(zhǔn)(含課程思政)
- 鐵路行車組織(高職)全套教學(xué)課件
- 注塑標(biāo)準(zhǔn)成型條件表電子表格模板
- 道閘系統(tǒng)施工方案
- 配置管理與漏洞修復(fù)
- 新版中國復(fù)發(fā)難治性急性髓系白血病診療指南
- 保潔巡查記錄表
- 成事的時間管理
- 國開大學(xué)2023年01月22503《學(xué)前兒童健康教育活動指導(dǎo)》期末考試答案
評論
0/150
提交評論