外文文献翻译-JSP发展历史中英文(共18页).docx
精选优质文档-倾情为你奉上专心-专注-专业JSP 的技术发展历史作者: Kathy Sierra and Bert Bates来源: Servlet&JSPJava Server Pages(JSP)是一种基于 web 的脚本编程技术,类似于网景公司的服务器端 Java 脚本语言 server-side JavaScript(SSJS)和微软的 Active Server Pages(ASP)。与 SSJS 和 ASP 相比,JSP 具有更好的可扩展性,并且它不专属于任何一家厂商或某一特定的 Web 服务器。尽 管 JSP 规范是由 Sun 公司制定的,但任何厂商都可以在自己的系统上实现 JSP。在 Sun 正式发布 JSP(Java Server Pages)之后,这种新的 Web 应用开发技术很快引起了人们 的关注。JSP 为创建高度动态的 Web 应用提供了一个独特的开发环境。按照 Sun 的说法,JSP 能够 适应市场上包括 Apache WebServer、IIS4.0 在内的 85%的服务器产品。本文将介绍 JSP 相关的知识,以及 JavaBean 的相关内容,当然都是比较粗略的介绍其中的基 本内容,仅仅起到抛砖引玉的作用,如果读者需要更详细的信息,请参考相应的 JSP 的书籍。1.1 概述JSP(Java Server Pages)是由 Sun Microsystems 公司倡导、许多公司参与一起建立的一种 动态网页技术标准,其在动态网页的建设中有其强大而特别的功能。JSP 与 Microsoft 的 ASP 技 术非常相似。两者都提供在 HTML 代码中混合某种程序代码、由语言引擎解释执行程序代码的能力。 下面我们简单的对它进行介绍。JSP 页面最终会转换成 servlet。因而,从根本上,JSP 页面能够执行的任何任务都可以用 servlet 来完成。然而,这种底层的等同性并不意味着 servlet 和 JSP 页面对于所有的情况都等 同适用。问题不在于技术的能力,而是二者在便利性、生产率和可维护性上的不同。毕竟,在特 定平台上能够用 Java 编程语言完成的事情,同样可以用汇编语言来完成,但是选择哪种语言依旧 十分重要。和单独使用 servlet 相比,JSP 提供下述好处:1) JSP 中 HTML 的编写与维护更为简单。JSP 中可以使用常规的 HTML:没有额外的反斜杠, 没有额外的双引号,也没有暗含的 Java 语法。2) 能够使用标准的网站开发工具。即使是那些对 JSP 一无所知的 HTML 工具,我们也可以使 用,因为它们会忽略 JSP 标签(JSP tags)。3) 可以对开发团队进行划分。Java 程序员可以致力于动态代码。Web 开发人员可以将经理集 中在表示层(presentation layer)上。对于大型的项目,这种划分极为重要。依据开发团队的 大小,及项目的复杂程度,可以对静态 HTML 和动态内容进行弱分离(weaker separation)和强 分离(stronger separation)。此处的讨论并不是说人们应该放弃使用 servlet 而仅仅使用 JSP。事实上,几乎所有的项目 都会同时用到这两种技术。在某些项目中,更适宜选用 servlet,而针对项目中的某些请求,我 们可能会在 MVC 构架下组合使用这两项技术。我们总是希望用适当的工具完成相对应的工作,仅 仅是 servlet 并不一定能够胜任所有工作。11.2 JSP 的由来Sun 公司的 JSP 技术,使 Web 页面开发人员可以使用 HTML 或者 XML 标识来设计和格式化最终 页面。使用 JSP 标识或者小脚本来生成页面上的动态内容(内容是根据请求来变化的)。Java Servlet 是 JSP 技术的基础,而且大型的 Web 应用程序的开发需要 Java Servlet 和 JSP 配合才能完成,Servlet 这个名称源于 Applet,现在国内的翻译方式很多,本书为了避免误会, 决定直接采用 Servlet 而不做任何翻译,读者如果愿意,可以称之为“小服务程序”。Servlet 其 实和传统的 CGI、ISAPI、NSAPI 等 Web 程序开发工具的作用是相似的,在使用 Java Servlet 以后, 用户不必再使用效率低下的 CGI 方式,也不必使用只能在某个固定 Web 服务器平台运行的 API 方 式来动态生成 Web 页面。许多 Web 服务器都支持 Servlet,即使不直接支持 Servlet 的 Web 服务 器也可以通过附加的应用服务器和模块来支持 Servlet。得益于 Java 的跨平台的特性,Servlet 也是平台无关的,实际上,只要符合 Java Servlet 规范,Servlet 是完全与平台无关且是与 Web 服务器无关的。由于 Java Servlet 内部是以线程方式提供服务,不必对于每个请求都启动一个进 程,并且利用多线程机制可以同时为多个请求服务,因此 Java Servlet 效率非常高。但 Java Servlet 也不是没有缺点,和传统的 CGI、ISAPI、NSAPI 方式相同,Java Servlet 是利用输出 HTML 语句来实现动态网页的,如果用 Java Servlet 来开发整个网站,动态部分和静 态页面的整合过程会非常难以实现。为了解决 Java Servlet 的这种缺点,SUN 推出了 JSP。许多年前,Marty 受到邀请,参加一个有关软件技术的小型研讨会.坐在 Marty 旁边的人是 James Gosling- Java 编程语言的发明者。隔几个位置,是来自华盛顿一家大型软件公司的高级 经理。在讨论过程中,研讨会的主席提出了 Jini 的议题,这在当时是一项新的 Java 技术。主席向 该经理询问他的想法.他回答说,虽然现在言之过早,但这看起来会是非常有前途的一项技术。他 们会持续关注这项技术,如果这项技术变得流行起来,他们会遵循公司的“接受并扩充(embrace and extend)”的策略.此时, Gosling 随意地插话说“你的意思其实就是不接受且不扩充 (disgrace and distend)。”在此, Gosling 的抱怨显示出,他感到这个公司会从其他公司那里拿走技术,用于他们自己的 目的.出人意料的是,形势已经完全不同。Java 团队并没有发明这一思想-将页面设计成由静 态 HTML 和用特殊标签标记的动态代码混合组成.。ColdFusion 多年前就已经这样做了。甚至 ASP(来自于前述经理所在公司的一项产品)都在 JSP 出现之前推广了这种方式。实际上,JSP 不只 采用了这种通用概念,它甚至使用许多和 ASP 相同的特殊标签。JSP 是建立在 Java servlets 模型之上的表达层技术,它使编写 HTML 变得更简单。像 SSJS 一样,它也允许你将静态 HTML 内容与服务器端脚本混合起来生成动态输出。JSP 把 Java 作为默 认的脚本语言,然而,就像 ASP 可以使用其他语言(如 JavaScript 和 VBScript)一样,JSP 规范也 允许使用其他语言。1.3 JSP 的特点按照脚本语言是服务于某一个子系统的语言这种论述,JSP 应当被看作是一种脚本语言。然 而,作为一种脚本语言,JSP 又显得过于强大了,在 JSP 中几乎可以使用全部的 Java 类。作为一种基于文本的、以显示为中心的开发技术,JSP 提供了 Java Servlet 的所有好处,并2且,当与一个 JavaBeans 类结合在一起时,JSP 提供了一种使内容和显示逻辑分开的简单方式。 分开内容和显示逻辑的好处是,更新页面外观的人员不必懂得 Java 代码,而更新 JavaBeans 类的 人员也不必是设计网页的行家里手,就可以用带 JavaBeans 类的 JSP 页面来定义 Web 模板,以建 立一个由具有相似的外观的页面组成的网站。JavaBeans 类完成数据提供,这样在模板中就没有 Java 代码,这意味着这些模板可以由一个 HTML 编写人员来维护。当然,也可以利用 Java Servlet 来控制网站的逻辑,通过 Java Servlet 调用 JSP 文件的方式来将网站的逻辑和内容分离。一般来说,在实际的 JSP 引擎中,JSP 页面在执行时是编译式,而不是解释式的。解释式的 动态网页开发工具如 ASP、PHP3 等由于速度等原因已经满足不了当前大型电子商务应用的需要了, 传统的开发技术都在向编译执行的方式改变,如 ASPASP+;PHP3PHP4。在 JSP 规范书中,并没有明确要求 JSP 中的程序代码部分(称为 Scriptlet)一定要用 Java 来 写。实际上,有一些 JSP 引擎就是采用的其他脚本语言,如 EMAC-Script、WebL 等,但实际上这 几种脚本语言也是构建在 Java 上面,编译为 Servlet 来实现的。按照 JSP 规范书写,和 Java 没 有任何关系的 Scriptlet 也是可以的,不过,由于 JSP 的强大功能主要在于能和JavaBeans、Enterprise JavaBeans 共同运转,所以即使是 Scriptlet 部分不使用 Java,编译成 的执行代码也应该是与 Java 相关的。1.4 JSP 的机制要理解 JSP 怎样联合以上各种所提到的技术的优点,从而轻而易举地实现各种效果,用户必 须首先了解“组件为中心的网页开发”和“页面为中心的网页开发”的区别。SSJS 和 ASP 都是在几年前推出的,那时网络还很年轻,没有人知道除了把所有的商务、数据 和表达逻辑统统堆进原始网页中之外还有什么更好的解决方法。这种以页面为中心的模型容易学 习并且得到相当快速的发展。然而,随着时间的推移,人们认识到这种方法不适于构建大型的、 可升级的 Web 应用程序。在脚本环境中书写的表达逻辑被锁在页面内,只有通过剪切和粘贴才能 被重用。表达逻辑通常和商务及数据逻辑混在一起,这使得当程序员试图改变一个应用程序的外 观而不想破坏与之紧密结合的商务逻辑时,应用程序的维护就变得十分艰难。其事实上,企业中 可重用组件的应用早已经很成熟,没有人愿意为它们的应用程序重写那些逻辑。HTML 和图形设计 师把它们的设计的实施工作交给了 Web 编写者,使他们不得不加倍工作 常常是手工编写,因 为没有合适的工具可以把服务器端脚本与 HTML 内容结合起来。简而言之,随着 Web 应用程序的复 杂性不断提升,以页面为中心的开发方式的局限性变得明显起来。与此同时,人们一直在寻找建立 Web 应用程序的更好方法,组件在客户机/服务器领域流行起 来。JavaBeans 和 ActiveX 被“快速应用程序开发”(RAD)工具发行商推广给 Java 和 Windows 应 用程序开发者用来快速开发复杂的程序。这些技术使某领域内的专家可以为本领域内的垂直应用 编写组件,而开发者可以直接拿来使用而不必掌握这一领域的专门技术。作为一种以组件为中心的开发平台,JSP 出现了。它以 JavaBeans 和 Enterprise JavaBeans(EJB)组件包含商务和数据逻辑的模型为基础,提供大量标签和一个脚本平台用来在 HTML 页中显示由 JavaBeans 产生或回送的内容。由于 JSP 的以组件为中心的性质,它可以被 Java 和非 Java 开发者同样使用。非 Java 开发者可以通过 JSP 的标签(Tags)来使用高级 Java 开发者创 建的 JavaBeans。Java 开发者不仅可以创建和使用 JavaBeans,还能在 JSP 页中使用 Java 语言来3更精密地控制基于底层 JavaBeans 的表达逻辑。现在来看看 JSP 是如何处理 HTTP 请求的。在基本请求模型中,一个请求直接被送到 JSP 页中。 JSP 代码控制着进行逻辑处理时与 JavaBeans 组件的交互,并在动态生成的、混合了静态 HTML 代 码的 HTML 页中显示结果。Beans 可以是 JavaBeans 或 EJB 组件。另外,更加复杂的请求模型可 看作从被请求页呼叫其他 JSP 页或 Java Servlets。JSP 引擎实际上要把 JSP 标签、JSP 页中的 Java 代码甚至连同静态 HTML 内容都转换为大块的 Java 代码。这些代码块被 JSP 引擎组织到用户看不到的 Java Servlet 中去,然后 Servlet 自动 把它们编译成 Java 字节码。这样,当网站的访问者请求一个 JSP 页时,在它不知道的情况下,一 个已经生成的、预编译过的 Servlet 实际上将完成所有的工作,非常隐蔽而又高效。因为 Servlet 是编译过的,所以网页中的 JSP 代码不需要在每次请求该页时被解释一遍。JSP 引擎只需 在 Servlet 代码最后被修改后编译一次,然后这个编译过的 Servlet 就可以被执行了。由于是 JSP 引擎自动生成并编译 Servlet,不用程序员动手编译代码,所以 JSP 能带给你高效的性能和快 速开发所需的灵活性。和传统的 CGI 相比较,JSP 有相当的优势。首先,在速度上,传统的 CGI 程序需要使用系统 的标准输入输出设备来实现动态网页的生成,而 JSP 是直接和服务器相关联的。而且对于 CGI 来 说,每一个访问就需要新增加一个进程来处理,进程不断地建立和销毁对于作为 Web 服务器的计 算机将是不小的负担。其次,JSP 是专门为 Web 开发而设计的,其目的是为了建立基于 Web 的应 用程序,其中包含了一整套的规范和工具。使用 JSP 技术可以很方便地将一大堆 JSP 页面组合成 为一个 Web 应用程序。4THE TECHNIQUE DEVELOPMENT HISTORY OF JSP By:Kathy Sierra and Bert BatesS ource: Servlet&JSPT he Java Server Pages( JSP) is a kind of according to web of the script plait distance technique, similar carries the script language of Java in the server of the Netscape company of server- side JavaScript( SSJS) and the Active Server Pages(ASP) of the Microsoft. JSP compares the SSJS and ASP to have better can expand sex, and it is no more exclusive than any factory or some one particular server of Web. Though the norm of JSP is to be draw up by the Sun company of, any factory can carry out the JSP on own system.The After Sun release the JSP( the Java Server Pages) formally, the this kind of new Web application development technique very quickly caused the people's concern. JSP provided a special development environment for the Web application that establishes the high dynamic state. According to the Sun parlance, the JSP can adapt to include the Apache WebServer, IIS4.0 on the market at inside of 85% server product.This chapter will introduce the related knowledge of JSP and Databases, and JavaBean related contents, is all certainly rougher introduction among them basic contents, say perhaps to is a Guide only, if the reader needs the more detailed information, pleasing the book of consult the homologous JSP.1.1 GENERALIZEThe JSP(Java Server Pages) is from the company of Sun Microsystems initiate, the many companies the participate to the build up the together of the a kind the of dynamic the state web the page technique standard, the it have the it in the construction the of the dynamic state the web page the strong but the do not the especially of the function. JSP and the technique of ASP of the Microsoft is very alike. Both all provide the ability that mixes with a certain procedure code and is explain by the language engine to carry out the procedure code in the code of HTML. Underneath we are simple of carry on the introduction to it.JSP pages are translated into servlets. So, fundamentally, any task JSP pages can perform could also be accomplished by servlets. However, this underlying equivalence does not mean that servlets and JSP pages are equally appropriate in all scenarios. The issue is not the power of the technology, it is the convenience, productivity, and maintainability of one or the other. After all, anything you can do on a particular computer platform in the Java programming language you could also do in assembly language. But it still matters which you choose.JSP provides the following benefits over servlets alone:1)It is easier to write and maintain the HTML. Your static code is ordinary HTML: no extra5backslashes, no double quotes, and no lurking Java syntax.2) You can use standard Web-site development tools. Even HTML tools that know nothing about JSP can be used because they simply ignore the JSP tags.3) You can divide up your development team. The Java programmers can work on the dynamic code. The Web developers can concentrate on the presentation layer. On large projects, this division is very important. Depending on the size of your team and the complexity of your project, you can enforce a weaker or stronger separation between the static HTML and the dynamic content.Now, this discussion is not to say that you should stop using servlets and use only JSP instead. By no means. Almost all projects will use both. For some requests in your project, you will use servlets. For others, you will use JSP. For still others, you will combine them with the MVC architecture . You want the appropriate tool for the job, and servlets, by themselves, do not complete your toolkit.1.2 SOURCE OF JSPThe technique of JSP of the company of Sun, making the page of Web develop the personnel can use the HTML perhaps marking of XML to design to turn the end page with format. Use the perhaps small script future life of marking of JSP becomes the dynamic state on the page contents.( the contents changes according to the claim of)The Java Servlet is a technical foundation of JSP, and the large Web applies the development of the procedure to need the Java Servlet to match with with the JSP and then can complete, this name of Servlet comes from the Applet, the local translation method of now is a lot of, this book in order not to misconstruction, decide the direct adoption Servlet but don't do any translation, if reader would like to, can call it as" small service procedure". The Servlet is similar to traditional CGI, ISAPI, NSAPI etc. Web procedure development the function of the tool in fact, at use the Java Servlet hereafter, the customer need not use again the lowly method of CGI of efficiency, also need not use only the ability come to born page of Web of dynamic state in the method of API that a certain fixed Web server terrace circulate. Many servers of Web all support the Servlet, even not support the Servlet server of Web directly and can also pass the additional applied server and the mold pieces to support the Servlet. Receive benefit in the characteristic of the Java cross-platform, the Servlet is also a terrace irrelevant, actually, as long as match the norm of Java Servlet, the Servlet is complete to have nothing to do with terrace and is to have nothing to do with server of Web. Because the Java Servlet is internal to provide the service by the line distance, need not start a progress to the each claimses, and make use of the multi-threading mechanism can at the same time for several claim service, therefore the efficiency of Java Servlet is very high.But the Java Servlet also is not to has no weakness, similar to traditional CGI, ISAPI, the NSAPI method, the Java Servlet is to make use of to output the HTML language sentence to carry out the dynamic state web page of, if develop the whole website with the Java Servlet, the integration process of the dynamic state part and the static state page is an evil-foreboding dream simply. For solving this kind of weakness of the Java Servlet, the SUN released the JSP.A number of years ago, Marty was invited to attend a small 20-person industry roundtable discussion on software technology. Sitting in the seat next to Marty was James Gosling, inventor of the Java programming language. Sitting several seats away was a high-level manager from a very large6software company in Redmond, Washington. During the discussion, the moderator brought up the subject of Jini, which at that time was a new Java technology. The moderator asked the manager what he thought of it, and the manager responded that it was too early to tell, but that it seemed to be an excellent idea. He went on to say that they would keep an eye on it, and if it seemed to be catching on, they would follow his company's usual "embrace and extend" strategy. At this point, Gosling lightheartedly interjected "You mean disgrace and distend."Now, the grievance that Gosling was airing was that he felt that this company would take technology from other companies and suborn it for their own purposes. But guess what? The shoe is on the other foot here. The Java community did not invent the idea of designing pages as a mixture of static HTML and dynamic code marked with special tags. For example, Cold Fusion did it years earlier. Even ASP (a product from the very software company of the aforementioned manager) popularized this approach before JSP came along and decided to jump on the bandwagon. In fact, JSP not only adopted the general idea, it even used many of the same special tags as ASP did.The JSP is an establishment at the model of Java servlets on of the expression layer technique, it makes the plait write the HTML to become more simple.Be like the SSJS, it also allows you carry the static state HTML contents and servers the script mix to put together the born dynamic state exportation. JSP the script language that the Java is the tacit approval, however, be like the ASP and can use other languages( such as JavaScript and VBScript), the norm of JSP also allows to use other languages.1.3JSP CHARACTERISTICSIs a service according to the script language in some one language of the statures system this kind of discuss, the JSP should be see make is a kind of script language. However, be a kind of script language, the JSP seemed to be too strong again, almost can use all Javas in the JSP.Be a kind of according to text originally of, take manifestation as the central development technique, the JSP provided all advantages of the Java Servlet, and, when combine with a JavaBeans together, providing a kind of make contents and manifestation that simple way that logic separate. Separate the contents and advantage of logical manifestations is, the personnel who renews the page external appearance need not know the code of Java, and renew the JavaBeans personnel also need not be design the web page of expert in hand, can use to take the page of JavaBeans JSP to define the template of Web, to build up a from have the alike external appearance of the web