《餐厅管理系统外文翻译文献.docx》由会员分享,可在线阅读,更多相关《餐厅管理系统外文翻译文献.docx(21页珍藏版)》请在三一办公上搜索。
1、餐厅管理系统外文翻译文献餐厅管理系统外文翻译文献 餐厅管理系统外文翻译文献 (文档含中英文对照即英文原文和中文翻译) 原文: JSP APPLICATION FRAMEWORKS 1 WHAT ARE APPLICATION FRAMEWORKS A framework is a reusable, semi-complete application that can be specialized to produce custom applications Johnson. Like people, software applications are more alike than they
2、 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 ap
3、plications. 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: Frameworks are the classi
4、c 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 1 餐厅管理系统外文翻译文献 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
5、would agree that frameworks such as Struts provide a significant return on investment compared to starting from scratch, especially for larger projects. 2 OTHER TYPES OF FRAMEWORKS The idea of a framework applies not only to applications but to application components as well. Throughout this article
6、, 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 prov
7、ide 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 a
8、ll popular choices among Struts developers. If you can use it with Java, you can use it with Struts. 3 ENABLING TECHNOLPGIES 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 reaso
9、n 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. 4 HYPERTE
10、XT 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. Th
11、e 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
12、 than HTTP. Some of these 2 餐厅管理系统外文翻译文献 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
13、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
14、 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
15、 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
16、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
17、 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
18、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 eff
19、icient, 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 refere
20、nce in the page address that a Java server can use to track users. Both approaches are 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 retur
21、ns 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
22、 3 餐厅管理系统外文翻译文献 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 f
23、iles, 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. 5 COMMON GATEWAY INTE
24、RFACE (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
25、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 p
26、rogram 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
27、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.
28、 Another drawback is that CGI programs tend to be platform dependent. A CGI program written for one operating system may not run on another. 6 JAVA SERVLETS Suns Java Servlet platform directly addresses the two main drawbacks of CGI programs. First, servlets offer better performance and utilization
29、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 4 餐厅管理系统外文翻译文
30、献 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
31、 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
32、 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. On
33、ce 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 u
34、se 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
35、 that, since servlets are multithreaded, Servlet developers must take special care to be sure their servlets are thread-safe. 7 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 st
36、atements to render the HTML. Code that looks like: out.println(One line of HTML.); out.println(Another line of HTML.); It 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
37、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 mi
38、xing 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 5 餐厅管理系统外文翻译文献 and templating technologies into a single component. To build Java Server Pages, developers start by creating H
39、TML 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
40、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
41、 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 c
42、an 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. 8 JAVABEANS JavaBean
43、s 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 non-argument con
44、structor. 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 patt
45、erns 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 m
46、ust 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 signatu
47、re for a weight property of the type Double would be: 6 餐厅管理系统外文翻译文献 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 i
48、n 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
49、 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 parame