文档库 最新最全的文档下载
当前位置:文档库 › 外文文献-绩效考核管理系统

外文文献-绩效考核管理系统

外文文献-绩效考核管理系统
外文文献-绩效考核管理系统

英文文献及翻译

文献题目An Overview of Servlet and JSP

Technology

文献作者Nagle ,Wiegley

题目翻译Servlet和JSP技术简述

参考人

院 (系)

专业班级

学号

1 A Servlet's Job

Servlets are Java programs that run on Web or application servers, acting as a middle layer between requests coming from Web browsers or other HTTP clients and databases or applications on the HTTP server. Their job is to perform the following tasks, as illustrated in Figure 1-1.

Figure 1-1Web middleware role

1.1 Read the explicit data sent by the client.

The end user normally enters this data in an HTML form on a Web page. However, the data could also come from an applet or a custom HTTP client program.

1.2 Read the implicit HTTP request data sent by the browser.

Figure 1-1 shows a single arrow going from the client to the Web server (the layer where servlets and JSP execute), but there are really two varieties of data: the explicit data that the end user enters in a form and the behind-the-scenes HTTP information. Both varieties are critical. The HTTP information includes cookies, information about media types and compression schemes the browser understands, and so on.

1.3 Generate the results.

This process may require talking to a database, executing an RMI or EJB call, invoking a Web service, or computing the response directly. Your real data may be in a relational database. Fine. But your database probably doesn't speak HTTP or return results in HTML, so the Web browser can't talk directly to the database. Even if it could, for security reasons, you probably would not want it to. The same argument applies to most other applications.You need the Web middle layer to extract the results inside a document.

1.4 Send the explicit data (i.e., the document) to the client.

This document can be sent in a variety of formats, including text (HTML or XML), binary (GIF images), or even a compressed format like gzip that is layered on top of some other underlying format. But, HTML is by far the most common format, so an important servlet/JSP task is to wrap the results inside of HTML.

1.5 Send the implicit HTTP response data.

Figure 1-1 shows a single arrow going from the Web middle layer (the servlet or JSP page) to the client. But, there are really two varieties of data sent: the document itself and the behind-the-scenes HTTP information. Again, both varieties are critical to effective development. Sending HTTP response data involves telling the browser or other client what type of document is being returned (e.g., HTML), setting cookies and caching parameters, and other such tasks.

2 Why Build Web Pages Dynamically?

many client requests can be satisfied by prebuilt documents, and the server would handle these requests without invoking servlets. In many cases, however, a static result is not sufficient, and a page needs to be generated for each request. There are a number of reasons why Web pages need to be built on-the-fly.

2.1 The Web page is based on data sent by the client.

For instance, the results page from search engines and order-confirmation pages at online stores are specific to particular user requests. You don't know what to display until you read the data that the user submits. Just remember that the user submits two kinds of data: explicit (i.e., HTML form data) and implicit (i.e., HTTP request headers). Either kind of input can be used to build the output page. In particular, it is quite common to build a user-specific page based on a cookie value.

2.2 The Web page is derived from data that changes frequently.

If the page changes for every request, then you certainly need to build the

response at request time. If it changes only periodically, however, you could do it two ways: you could periodically build a new Web page on the server (independently of client requests), or you could wait and only build the page when the user requests it. The right approach depends on the situation, but sometimes it is more convenient to do the latter: wait for the user request. For example, a weather report or news headlines site might build the pages dynamically, perhaps returning a previously built page if that page is still up to date.

2.3 The Web page uses information from corporate databases or other server-side sources.

If the information is in a database, you need server-side processing even if the client is using dynamic Web content such as an applet. Imagine using an applet by itself for a search engine site:

"Downloading 50 terabyte applet, please wait!" Obviously, that is silly; you need to talk to the database. Going from the client to the Web tier to the database (a three-tier approach) instead of from an applet directly to a database (a two-tier approach) provides increased flexibility and security with little or no performance penalty. After all, the database call is usually the rate-limiting step, so going through the Web server does not slow things down. In fact, a three-tier approach is often faster because the middle tier can perform caching and connection pooling.

In principle, servlets are not restricted to Web or application servers that handle HTTP requests but can be used for other types of servers as well. For example, servlets could be embedded in mail servers to extend their functionality. And, a servlet API for SIP (Session Initiation Protocol) servers was recently standardized (see ). In practice, however, this use of servlets has not caught on, and we'll only be discussing HTTP servlets.

中文翻译

1Servlet的功能

Servlet是运行在Web或应用服务器上的Java程序,它是一个中间层,负责连接来自Web浏览器或其他HTTP客户程序的请求和HTTP服务器上的数据库或应用程序。Servlet的工作是执行西门的任务,如图1.1所示。

图1.1Web中间件的作用

1.1读取客户发送的显式数据

最终用户一般在页面的HTML表单中输入这些数据。然而,数据还有可能来自applet或定制的HTTP客户程序。

1.2读取由浏览器发送的隐式请求数据

图1.1中显示了一条从客户端到Web服务器的单箭头,但实际上从客户端传送到Web服务器的数据有两种,它们分别为用户在表单中输入的显式数据,以及后台的HTTP信息。两种数据都很重要。HTTP信息包括cookie、浏览器所能识别的媒体类型和压缩模式等。

1.3生成结果

这个过程可能需要访问数据库、执行RMI或EJB调用、调用Web服务,或者直接计算得出对应的响应。实际的数据可能存储在关系型数据库中。该数据库可能不理解HTTP,或者不能返回HTML形式的结果,所有Web浏览器不能直接与数据库进行会话。即使它能够做到这一点,为了安全上的考虑,我们也不希望让它这么做。对应大多数其他应用程序,也存在类似的问题。因此,我们需要Web中间层从HTTP流中提取输入数据,与应用程序会话,并将结果嵌入到文档

中。

1.4向客户发送显式数据(即文档)

这个文档可以用各种格式发送,包括文本(HTML或XML),二进制(GIF 图),甚至可以式建立在其他底层格式之上的压缩格式,如gzip。但是,到目前为止,HTML式最常用的格式,故而servelt和JSP的重要任务之一就式将结果包装到HTML中。

1.5发送隐式的HTTP响应数据

图1.1中显示了一条从Web中间层到客户端的单箭头。但是,实际发送的数据有两种:文档本身,以及后台的HTTP信息。同样,两种数据对开发来说都式至关重要的。HTTP响应数据的发送过程涉及告知浏览器或其他客户程序所返回文档的类型(如HTML),设置cookie和缓存参数,以及其他类似的任务。

2动态构建网页的原因

预先建立的文档可以满足客户的许多请求,服务器无需调用servlet就可以处理这些请求。然而,许多情况下静态的结果不能满足要求,我们需要针对每个请求生成一个页面。实时构建页面的理由有很多种。

2.1网页基于客户发送的数据

例如,搜索引擎生成的页面,以及在线商店的订单确认页面,都要针对特定的用户请求而产生。在没有读取到用户提交的数据之前,我们不知道应该显示什么。要记住,用户提交两种类型的数据:显示(即HTML表单的数据)和隐式(即HTTP请求的报头)。两种输入都可用来构建输出页面。基于cookie值针对具体用户构建页面的情况尤其普遍。

2.2页面由频繁改变的数据导出

如果页面需要根据每个具体的请求做出相应的改变,当然需要在请求发生时构建响应。但是,如果页面周期性地改变,我们可以用两种方式来处理它:周期性地在服务器上构建新的页面(和客户请求无关),或者仅仅在用户请求该页面时再构建。具体应该采用哪种方式要根据具体情况而定,但后一种方式常常更为

方便,因为它只需简单地等待用户的请求。例如,天气预报或新闻网站可能会动态地构建页面,也有可能会返回之前构建的页面(如果它还是最新的话)。

2.3页面中使用了来自公司数据库或其他数据库断数据源的信息

如果数据存储在数据库中,那么,即使客户端使用动态Web内容,比如applet,我们依旧需要执行服务器端处理。想象以下,如果一个搜索引擎网站完全使用applet,那么用户将会看到:“正在下载50TB的applet,请等待!”。显然,这样很愚蠢;这种情况下,我们需要与数据库进行会话。从客户端到Web层再到数据库(三层结构),要比从applet直接到数据库(二层结构)更灵活,也更安全,而性能上的损失很少甚至没有。毕竟数据库调用通常是对速度影响最大的步骤,因而,经过中间层可以执行高速缓存和连接共享。

理论上讲,servelt并非只用于处理HTTP请求的Web服务器或应用服务器,它同样可以用于其他类型的服务器。例如,servlet能够嵌入到FTP或邮件服务器中,扩展他们的功能。而且,用于会话启动协议服务器的servlet API最近已经被标准化(参见)。但在实践中,servelt的这种用法尚不流行,在此,我们只论述HTTP Servlet。

相关文档