9毕业设计(论文)外文翻译.doc_第1页
9毕业设计(论文)外文翻译.doc_第2页
9毕业设计(论文)外文翻译.doc_第3页
9毕业设计(论文)外文翻译.doc_第4页
9毕业设计(论文)外文翻译.doc_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

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

文档简介

大连交通大学信息工程学院2011届本科生毕业设计(论文)外文翻译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)是可重用的,半成品的应用程序,可以用来产生专门的定制程序。象人一样,软件应用的相似性比不同点要多。它们运行在相似的机器上,期望从相同的设备输入信息,输出到相同的显示设备,并且将数据存储到相同的硬盘设备。开发传统桌面应用的开发人员更习惯于那些可以涵盖应用开发同一性的工具包和开发环境。构架在这些公共基础上的应用框架可以为开发人员提供可以为他们的产品提供可重用服务的基础架构。框架向开发人员提供一系列具有以下特征的骨架组件:1已经知道它们在其它程序上工作得很好;2它们随时可以在下一个项目中使用;3它们可以被组织的其它团队使用;对于框架是典型的构建还是购买命题。如果你自己构建它,在你完成时你就会理解它,但是在你被融入之前又将花费多长时间呢?如果要购买,你必须得克服学习曲线,同样,在你可以用它进行工作之前又得花多长时间?这里没有所谓正确答案,但许多观察者都会同意,象Struts这样的框架能提供比从头开始开发更显著的投资回报,特别是对于大型项目来说。使用的技术:使用Struts的应用开发使用了大量的其他基础技术。这些技术并不是专门针对Struts,而是所有Java web 应用都可以使用的。开发者使用Struts之类的框架是为了隐藏在诸如HTTP,CGI,以及JSP之类技术后面的繁琐的细节。作为一个Struts开发者,你并不需要知晓所有的相关知识,但是这些基本技术的工作原理可能有助于你针对棘手问题设计出创造性的方案。Java servlet:Sun公司的Java Servlet平台直接解决了CGI程序的两个主要缺点:首先,servlet 比常规CGI 程序提供更好的性能和资源利用。其次,一次编写,随处运行的JAVA特性意味着servlet在有JVM 的操作系统间是轻便的可移动的。Servlet看起来好像是一个微小的web server。它接受请求并产生响应。但,和常规web server不同,servlet API 是专门设计来帮助Java 开发人员创建动态应用的。Servlet 本身是要编译成字节码的Java类,就像其他Java对象一样。Servlet访问HTTP 特定服务的API,但它仍然是一个运行于程序之中的Java 对象,并可以利用所有的Java 资产。为了使常规web servers能访问servlet,servlet被安插在一个容器之中。Servlet容器连接到Web服务器。每servlet 都可以声明它可以处理何种样式的URL。当符合所注册样式的请求到达,web server将请求传递给容器,容器则调用响应的servlet。但和CGI 程序不同,并不是针对每个请求都要创建一个新的servlet。一旦容器实例化了一个servlet,它就仅为每个新的请求创建一个新的线程。Java线程可比使用CGI程序的服务器处理开销小多了。一旦servlet被创建,使用它处理额外的请求仅带来很小的额外开销。Servlet开发人员可以使用init() 方法保持对昂贵资源的引用,比如到数据库或者EJB Home接口的连接,以便它们可以在不同的请求之间进行共享。获得这些资源要耗费数秒时间,这比大多数冲浪者愿意等的时间要长些。Servlet的另一个好处是,它是多线程的,servlet开发人员必须特别注意确保它们的servlet是线程安全的。学习servlet 编程,我们推荐Java Servlets by Example, 作者Alan R. WilliamsonWilliamson。JavaServer Pages:虽然servlets对CGI程序来说前进了一大步,但它也不是万能灵药。为了产生响应,开发人员不得不使用大量的println语句来生成HTML。比如这样的代码:out.println(One line of HTML.);out.println(Another line of HTML.);在产生HTTP响应的Servlet 中是很普遍的。也有一些库有助于你产生HTML。随着应用越来越复杂,Java开发人员将不再扮演HTML页面设计的角色。同时,大多数项目经理更喜欢将团队分成不同的小组。 它们喜欢HTML设计人员处理表现层的工作,而Java工程师则专注于业务逻辑。单独使用servlet的做法鼓励混合标记和业务逻辑,很难区分团队人员的专业工作。为解决这个问题,Sun提出了一个将脚本和模板技术结合到一个组件中的服务器页面技术(JavaServer Pages)。为创建JSP页面, 开发者按创建HTML页面类似的方式创建页面,使用相同的HTML 语法。为将动态内容引入页面,开发人员可以将脚本元素置入页面之中。脚本元素是一些标记,封装了可以被JSP识别的逻辑。你可以在JSP页面中很容易的识别出脚本元素,他们被封装在一对标记中。为了识别JSP页面,文件需要保存为扩展名.jsp。当一个客户请求JSP页面时,容器将页面翻译成Java servlet 源代码文件,并将它编译成Java 类文件就象你写的servlet文件一样。在运行时,容器也能检测JSP文件和相应的类的最后更新时间。如果,JSP 文件自上次编译以来被修改了,容器将重新翻译和编译JSP文件。项目经理现在可以将表现层分派给HTML 开发人员,将业务逻辑工作分派给JAVA开发人员。重要的是记住,JSP页面事实上是一个servlet。你可以在servlet做的,也可以在JSP中做。JavaBean:JavaBean是一种 Java类,它遵从一定的设计模式,使它们易于和其他开发工具和组件一起使用。定义 JavaBean 是一种JAVA 语言写成的可重用组件。要编写JavaBean,类必须是具体类和公共类,并且具有无参数的构造器(NON-ARGS CONSTRUCTOR)。JavaBean通过提供符合一致性设计模式的公共访问方法将内部字段暴露称为属性。众所周知,属性名称也符合这种模式,其他JAVA 类可以通过自省机制发现和操作这些JavaBean 属性。我们必须做的如下:1编写一个类,通过实现doStart()或者doEnd()方法来实现javax.servlet.jsp.tagext.TagSupport 或者javax.servlet.jsp.tagext.BodyTagSupport接口。这些方法获得一个JspWriter对象,你可以

温馨提示

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

评论

0/150

提交评论