JSP 应用框架-外文及翻译.doc

上传人:文初 文档编号:2103677 上传时间:2019-04-25 格式:DOC 页数:15 大小:60.04KB
下载 相关 举报
JSP 应用框架-外文及翻译.doc_第1页
第1页 / 共15页
JSP 应用框架-外文及翻译.doc_第2页
第2页 / 共15页
JSP 应用框架-外文及翻译.doc_第3页
第3页 / 共15页
JSP 应用框架-外文及翻译.doc_第4页
第4页 / 共15页
JSP 应用框架-外文及翻译.doc_第5页
第5页 / 共15页
点击查看更多>>
资源描述

1、毕业论文外文翻译JSP application frameworksbrian wright、michael freedmanhttp:/ What 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 ru

2、n 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

3、 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 application

4、s.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

5、 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.Other types of frameworks:The

6、 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. Lik

7、e 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

8、 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 enab

9、ling 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 wor

10、king 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

11、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 comp

12、uter 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. Becau

13、se 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

14、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 H

15、TTP 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 th

16、e HTTP request contains the method, followed by the locationof 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

17、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 ve

18、rsion, 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, s

19、ends 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. (Ignorance is not always bliss.Cookies and URL rewriting are two common ways to keep track of users between

20、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 standa

21、rd 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 h

22、ypertext 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 cust

23、omized, 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

24、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

25、 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 run

26、s 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 a

27、nd 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 proce

28、ss 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 m

29、ain 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 an

30、d 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

31、 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

32、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 un

33、like 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 addit

34、ional 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

35、 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 Wi

36、lliamson. 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.

37、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 HTM

38、L 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,

39、 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 ol

40、d 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 b

41、e 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 scra

42、tch. 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 devel

43、opers, 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 p

44、atterns 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

45、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 t

46、wo 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

47、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:publi

48、c 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 metho

49、d 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 wi

展开阅读全文
相关资源
相关搜索
资源标签

当前位置:首页 > 学术论文资料库 > 毕业论文

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。