9畢業(yè)設(shè)計(jì)(論文)外文翻譯.doc_第1頁(yè)
9畢業(yè)設(shè)計(jì)(論文)外文翻譯.doc_第2頁(yè)
9畢業(yè)設(shè)計(jì)(論文)外文翻譯.doc_第3頁(yè)
9畢業(yè)設(shè)計(jì)(論文)外文翻譯.doc_第4頁(yè)
9畢業(yè)設(shè)計(jì)(論文)外文翻譯.doc_第5頁(yè)
已閱讀5頁(yè),還剩4頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

大連交通大學(xué)信息工程學(xué)院2011屆本科生畢業(yè)設(shè)計(jì)(論文)外文翻譯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)用程序,可以用來(lái)產(chǎn)生專(zhuān)門(mén)的定制程序。象人一樣,軟件應(yīng)用的相似性比不同點(diǎn)要多。它們運(yùn)行在相似的機(jī)器上,期望從相同的設(shè)備輸入信息,輸出到相同的顯示設(shè)備,并且將數(shù)據(jù)存儲(chǔ)到相同的硬盤(pán)設(shè)備。開(kāi)發(fā)傳統(tǒng)桌面應(yīng)用的開(kāi)發(fā)人員更習(xí)慣于那些可以涵蓋應(yīng)用開(kāi)發(fā)同一性的工具包和開(kāi)發(fā)環(huán)境。構(gòu)架在這些公共基礎(chǔ)上的應(yīng)用框架可以為開(kāi)發(fā)人員提供可以為他們的產(chǎn)品提供可重用服務(wù)的基礎(chǔ)架構(gòu)??蚣芟蜷_(kāi)發(fā)人員提供一系列具有以下特征的骨架組件:1已經(jīng)知道它們?cè)谄渌绦蛏瞎ぷ鞯煤芎茫?它們隨時(shí)可以在下一個(gè)項(xiàng)目中使用;3它們可以被組織的其它團(tuán)隊(duì)使用;對(duì)于框架是典型的構(gòu)建還是購(gòu)買(mǎi)命題。如果你自己構(gòu)建它,在你完成時(shí)你就會(huì)理解它,但是在你被融入之前又將花費(fèi)多長(zhǎng)時(shí)間呢?如果要購(gòu)買(mǎi),你必須得克服學(xué)習(xí)曲線(xiàn),同樣,在你可以用它進(jìn)行工作之前又得花多長(zhǎng)時(shí)間?這里沒(méi)有所謂正確答案,但許多觀察者都會(huì)同意,象Struts這樣的框架能提供比從頭開(kāi)始開(kāi)發(fā)更顯著的投資回報(bào),特別是對(duì)于大型項(xiàng)目來(lái)說(shuō)。使用的技術(shù):使用Struts的應(yīng)用開(kāi)發(fā)使用了大量的其他基礎(chǔ)技術(shù)。這些技術(shù)并不是專(zhuān)門(mén)針對(duì)Struts,而是所有Java web 應(yīng)用都可以使用的。開(kāi)發(fā)者使用Struts之類(lèi)的框架是為了隱藏在諸如HTTP,CGI,以及JSP之類(lèi)技術(shù)后面的繁瑣的細(xì)節(jié)。作為一個(gè)Struts開(kāi)發(fā)者,你并不需要知曉所有的相關(guān)知識(shí),但是這些基本技術(shù)的工作原理可能有助于你針對(duì)棘手問(wèn)題設(shè)計(jì)出創(chuàng)造性的方案。Java servlet:Sun公司的Java Servlet平臺(tái)直接解決了CGI程序的兩個(gè)主要缺點(diǎn):首先,servlet 比常規(guī)CGI 程序提供更好的性能和資源利用。其次,一次編寫(xiě),隨處運(yùn)行的JAVA特性意味著servlet在有JVM 的操作系統(tǒng)間是輕便的可移動(dòng)的。Servlet看起來(lái)好像是一個(gè)微小的web server。它接受請(qǐng)求并產(chǎn)生響應(yīng)。但,和常規(guī)web server不同,servlet API 是專(zhuān)門(mén)設(shè)計(jì)來(lái)幫助Java 開(kāi)發(fā)人員創(chuàng)建動(dòng)態(tài)應(yīng)用的。Servlet 本身是要編譯成字節(jié)碼的Java類(lèi),就像其他Java對(duì)象一樣。Servlet訪問(wèn)HTTP 特定服務(wù)的API,但它仍然是一個(gè)運(yùn)行于程序之中的Java 對(duì)象,并可以利用所有的Java 資產(chǎn)。為了使常規(guī)web servers能訪問(wèn)servlet,servlet被安插在一個(gè)容器之中。Servlet容器連接到Web服務(wù)器。每servlet 都可以聲明它可以處理何種樣式的URL。當(dāng)符合所注冊(cè)樣式的請(qǐng)求到達(dá),web server將請(qǐng)求傳遞給容器,容器則調(diào)用響應(yīng)的servlet。但和CGI 程序不同,并不是針對(duì)每個(gè)請(qǐng)求都要?jiǎng)?chuàng)建一個(gè)新的servlet。一旦容器實(shí)例化了一個(gè)servlet,它就僅為每個(gè)新的請(qǐng)求創(chuàng)建一個(gè)新的線(xiàn)程。Java線(xiàn)程可比使用CGI程序的服務(wù)器處理開(kāi)銷(xiāo)小多了。一旦servlet被創(chuàng)建,使用它處理額外的請(qǐng)求僅帶來(lái)很小的額外開(kāi)銷(xiāo)。Servlet開(kāi)發(fā)人員可以使用init() 方法保持對(duì)昂貴資源的引用,比如到數(shù)據(jù)庫(kù)或者EJB Home接口的連接,以便它們可以在不同的請(qǐng)求之間進(jìn)行共享。獲得這些資源要耗費(fèi)數(shù)秒時(shí)間,這比大多數(shù)沖浪者愿意等的時(shí)間要長(zhǎng)些。Servlet的另一個(gè)好處是,它是多線(xiàn)程的,servlet開(kāi)發(fā)人員必須特別注意確保它們的servlet是線(xiàn)程安全的。學(xué)習(xí)servlet 編程,我們推薦Java Servlets by Example, 作者Alan R. WilliamsonWilliamson。JavaServer Pages:雖然servlets對(duì)CGI程序來(lái)說(shuō)前進(jìn)了一大步,但它也不是萬(wàn)能靈藥。為了產(chǎn)生響應(yīng),開(kāi)發(fā)人員不得不使用大量的println語(yǔ)句來(lái)生成HTML。比如這樣的代碼:out.println(One line of HTML.);out.println(Another line of HTML.);在產(chǎn)生HTTP響應(yīng)的Servlet 中是很普遍的。也有一些庫(kù)有助于你產(chǎn)生HTML。隨著應(yīng)用越來(lái)越復(fù)雜,Java開(kāi)發(fā)人員將不再扮演HTML頁(yè)面設(shè)計(jì)的角色。同時(shí),大多數(shù)項(xiàng)目經(jīng)理更喜歡將團(tuán)隊(duì)分成不同的小組。 它們喜歡HTML設(shè)計(jì)人員處理表現(xiàn)層的工作,而Java工程師則專(zhuān)注于業(yè)務(wù)邏輯。單獨(dú)使用servlet的做法鼓勵(lì)混合標(biāo)記和業(yè)務(wù)邏輯,很難區(qū)分團(tuán)隊(duì)人員的專(zhuān)業(yè)工作。為解決這個(gè)問(wèn)題,Sun提出了一個(gè)將腳本和模板技術(shù)結(jié)合到一個(gè)組件中的服務(wù)器頁(yè)面技術(shù)(JavaServer Pages)。為創(chuàng)建JSP頁(yè)面, 開(kāi)發(fā)者按創(chuàng)建HTML頁(yè)面類(lèi)似的方式創(chuàng)建頁(yè)面,使用相同的HTML 語(yǔ)法。為將動(dòng)態(tài)內(nèi)容引入頁(yè)面,開(kāi)發(fā)人員可以將腳本元素置入頁(yè)面之中。腳本元素是一些標(biāo)記,封裝了可以被JSP識(shí)別的邏輯。你可以在JSP頁(yè)面中很容易的識(shí)別出腳本元素,他們被封裝在一對(duì)標(biāo)記中。為了識(shí)別JSP頁(yè)面,文件需要保存為擴(kuò)展名.jsp。當(dāng)一個(gè)客戶(hù)請(qǐng)求JSP頁(yè)面時(shí),容器將頁(yè)面翻譯成Java servlet 源代碼文件,并將它編譯成Java 類(lèi)文件就象你寫(xiě)的servlet文件一樣。在運(yùn)行時(shí),容器也能檢測(cè)JSP文件和相應(yīng)的類(lèi)的最后更新時(shí)間。如果,JSP 文件自上次編譯以來(lái)被修改了,容器將重新翻譯和編譯JSP文件。項(xiàng)目經(jīng)理現(xiàn)在可以將表現(xiàn)層分派給HTML 開(kāi)發(fā)人員,將業(yè)務(wù)邏輯工作分派給JAVA開(kāi)發(fā)人員。重要的是記住,JSP頁(yè)面事實(shí)上是一個(gè)servlet。你可以在servlet做的,也可以在JSP中做。JavaBean:JavaBean是一種 Java類(lèi),它遵從一定的設(shè)計(jì)模式,使它們易于和其他開(kāi)發(fā)工具和組件一起使用。定義 JavaBean 是一種JAVA 語(yǔ)言寫(xiě)成的可重用組件。要編寫(xiě)JavaBean,類(lèi)必須是具體類(lèi)和公共類(lèi),并且具有無(wú)參數(shù)的構(gòu)造器(NON-ARGS CONSTRUCTOR)。JavaBean通過(guò)提供符合一致性設(shè)計(jì)模式的公共訪問(wèn)方法將內(nèi)部字段暴露稱(chēng)為屬性。眾所周知,屬性名稱(chēng)也符合這種模式,其他JAVA 類(lèi)可以通過(guò)自省機(jī)制發(fā)現(xiàn)和操作這些JavaBean 屬性。我們必須做的如下:1編寫(xiě)一個(gè)類(lèi),通過(guò)實(shí)現(xiàn)doStart()或者doEnd()方法來(lái)實(shí)現(xiàn)javax.servlet.jsp.tagext.TagSupport 或者javax.servlet.jsp.tagext.BodyTagSupport接口。這些方法獲得一個(gè)JspWriter對(duì)象,你可以

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論