JSP 应用框架 毕业论文外文翻译.doc_第1页
JSP 应用框架 毕业论文外文翻译.doc_第2页
JSP 应用框架 毕业论文外文翻译.doc_第3页
JSP 应用框架 毕业论文外文翻译.doc_第4页
JSP 应用框架 毕业论文外文翻译.doc_第5页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

外文科技资料翻译英文原文jsp application frameworkswhat are application frameworks:a framework is a reusable, semi-complete application that can be specialized to produce custom applications. 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 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 on investment compared to starting from scratch, especially for larger projects.other types of frameworks:the idea of a framework applies not only to applications but to application componentsas well. throughout this article, we introduce other types of frameworks that you can use with struts. these include the lucene search engine, the scaffold toolkit, the struts validator, and the tiles tag library. like application frameworks, these tools provide semi-complete versions of a subsystem that can be specialized to provide a custom component. some frameworks have been linked to a proprietary development environment. this is not the case with struts or any of the other frameworks shown in this book. you can use any development environment with struts: visual age for java, jbuilder, eclipse, emacs, and textpad are all popular choices among struts developers. if you can use it with java, you can use it with struts.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.hypertext transfer protocol (http):when mediating talks between nations, diplomats often follow a formal protocol. diplomatic protocols are designed to avoid misunderstandings and to keep negotiations from breaking down. in a similar vein, when computers need to talk, they also follow a formal protocol. the protocol defines how data is transmitted and how to decode it once it arrives. web applications use the hypertext transfer protocol (http) to move data between the browser running on your computer and the application running on the server.many server applications communicate using protocols other than http. some of these maintain an ongoing connection between the computers. the application server knows exactly who is connected at all times and can tell when a connection is dropped. because they know the state of each connection and the identity of each person using it, these are known as stateful protocols.by contrast, http is known as a stateless protocol. an http server will accept any request from any client and will always provide some type of response, even if the response is just to say no. without the overhead of negotiating and retaining a connection, stateless protocols can handle a large volume of requests. this is one reason why the internet has been able to scale to millions of computers.another reason http has become the universal standard is its simplicity. an http request looks like an ordinary text document. this has made it easy for applications to make http requests. you can even send an http request by hand using a standard utility such as telnet. when the http response comes back, it is also in plain text that developers can read. the first line in the http request contains the method, followed by the location of the requested resource and the version of http. zero or more http request headers follow the initial line. the http headers provide additional information to the server. this can include the browser type and version, acceptable document types, and the browsers cookies, just to name a few. of the seven request methods, get and post are by far the most popular.once the server has received and serviced the request, it will issue an http response. the first line in the response is called the status line and carries the http protocol version, a numeric status, and a brief description of the status. following the status line, the server will return a set of http response headers that work in a way similar to the request headers. as we mentioned, http does not preserve state information between requests.the server logs the request, sends the response, and goes blissfully on to the next request. while simple and efficient, a stateless protocol is problematic for dynamic applications that need to keep track of their users.cookies and url rewriting are two common ways to keep track of users between requests. a cookie is a special packet of information on the users computer. url rewriting stores a special reference in the page address that a java server can use to track users. neither approach is seamless, and using either means extra work when developing a web application. on its own, a standard http web server does not traffic in dynamic content. it mainly uses the request to locate a file and then returns that file in the response. the file is typically formatted using hypertext markup language (html) w3c, html that the web browser can format and display. the html page often includes hypertext links to other web pages and may display any number of other goodies, such as images and videos. the user clicks a link to make another request, and the process begins a new.standard web servers handle static content and images quite well but need a helping hand to provide users with a customized, dynamic response. definition:static content on the web comes directly from text or data files, like html or jpeg files. these files might be changed from time to time, but they are not altered automatically when requested by a web browser. dynamic content, on the other hand, is generated on the fly, typically in response to an individualized request from a browser.common gateway interface (cgi):the first widely used standard for producing dynamic content was the common gateway interface (cgi). cgi uses standard operating system features, such as environment variables and standard input and output, to create a bridge, or gateway, between the web server and other applications on the host machine. the other applications can look at the request sent to them by the web server and create a customized response.when a web server receives a request thats intended for a cgi program, it runs that program and provides the program with information from the incoming request. the cgi program runs and sends its output back to the server. the web server then relays the response to the browser.cgi defines a set of conventions regarding what information it will pass as environment variables and how it expects standard input and output to be used. like http, cgi is flexible and easy to implement, and a great number of cgi-aware programs have been written.the main drawback to cgi is that it must run a new copy of the cgi-aware program for each request. this is a relatively expensive process that can bog down high-volume sites where thousands of requests are serviced per minute. another drawback is that cgi programs tend to be platform dependent. a cgi program written for one operating system may not run on another.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 multitowered, 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. java server 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.java bean: java bean 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 java bean is a reusable software component written in java. to qualify as a java bean, the class must be concrete and public, and have a nonargument constructor. java bean 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 java bean properties. the java bean design patterns provide access to the beans internal state through two flavors of methods: accessors are used to read a java beans state; mutators are used to change a java beans 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 be public 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 java beans properties by looking for methods prefixed by set, is, or get. if a component finds such a signature on a java bean, it knows that the method can be used to access or change the beans properties.sun introduced java beans 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 java beans. the dynamic data for a page can be passed as a java bean, and the jsp tag can then use the beans properties to customize the output.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.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 java beans. we also looked at the model 2 application architecture to see how it is used to combine 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.中文翻译jsp 应用框架什么是应用框架:框架(framework)是可重用的,半成品的应用程序,可以用来产生专门的定制程序。象人一样,软件应用的相似性比不同点要多。它们运行在相似的机器上,期望从相同的设备输入信息,输出到相同的显示设备,并且将数据存储到相同的硬盘设备。开发传统桌面应用的开发人员更习惯于那些可以涵盖应用开发同一性的工具包和开发环境。构架在这些公共基础上的应用框架可以为开发人员提供可以为他们的产品提供可重用服务的基础架构。框架向开发人员提供一系列具有以下特征的骨架组件:1已经知道它们在其它程序上工作得很好;2它们随时可以在下一个项目中使用;3它们可以被组织的其它团队使用;对于框架是典型的构建还是购买命题。如果你自己构建它,在你完成时你就会理解它,但是在你被融入之前又将花费多长时间呢?如果要购买,你必须得克服学习曲线,同样,在你可以用它进行工作之前又得花多长时间?这里没有所谓正确答案,但许多观察者都会同意,象struts这样的框架能提供比从头开始开发更显著的投资回报,特别是对于大型项目来说。其它类型的框架:框架的概念不仅用于应用程序也可用于组件。在其它的资料里面,我们也介绍了一些可以和struts一起使用的框架。这些包括lucene搜索引擎,scaffold工具包,struts验证器,以及tiles标签库。与应用框架一样,这些工具也提供了一些半完成

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论