JSP 应用框架 毕业论文外文翻译.doc

上传人:白大夫 文档编号:4508306 上传时间:2019-11-13 格式:DOC 页数:14 大小:64.56KB
返回 下载 相关 举报
JSP 应用框架 毕业论文外文翻译.doc_第1页
第1页 / 共14页
JSP 应用框架 毕业论文外文翻译.doc_第2页
第2页 / 共14页
JSP 应用框架 毕业论文外文翻译.doc_第3页
第3页 / 共14页
JSP 应用框架 毕业论文外文翻译.doc_第4页
第4页 / 共14页
JSP 应用框架 毕业论文外文翻译.doc_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《JSP 应用框架 毕业论文外文翻译.doc》由会员分享,可在线阅读,更多相关《JSP 应用框架 毕业论文外文翻译.doc(14页珍藏版)》请在三一文库上搜索。

1、 外文科技资料翻译英文原文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

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

3、d 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 ne

4、xt 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

5、 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 onl

6、y 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 tool

7、s 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 environmen

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

9、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 techno

10、logies 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 v

11、ein, 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 o

12、n 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 con

13、nection 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 overhe

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

15、 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 metho

16、d, 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,

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

18、rief 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 bli

19、ssfully 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 us

20、ers 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 main

21、ly 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

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

23、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 fro

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

25、rver 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 t

26、he 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 HT

27、TP, 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 reque

28、sts 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 perf

29、ormance 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

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

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

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

33、est. 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 developer

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

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

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

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

38、o 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 templatin

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

40、ncapsulate 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 int

41、o 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

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

43、 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.

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

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

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

47、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 wit

48、h 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, a

49、ccessors 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 acce

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1