登录

  • 登录
  • 忘记密码?点击找回

注册

  • 获取手机验证码 60
  • 注册

找回密码

  • 获取手机验证码60
  • 找回
毕业论文网 > 外文翻译 > 计算机类 > 计算机科学与技术 > 正文

JSP的技术发展史 Servlet和jsp技术的综述外文翻译资料

 2022-09-18 05:09  

THE TECHNIQUE DEVELOPMENT HISTORY OF JSP

An Overview of Servlet and JSP Technology

By:Kathy Sierra and Bert Bates,Nagle ,Wiegley

Source: Servletamp;JSP

Abstract: Servlet program running in the server-side, dynamically generated Web page with the traditional CGI and many other similar compared to CGI technology, Java Servlet with a more efficient, easier to use, more powerful and has better portability, more savings to invest. .

The 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.

Keywords: JSP Technology;Servlet;HTTP server

GENERALIZE

The 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:

bull; It is easier to write and maintain the HTML. Your static code is ordinary HTML: no extra backslashes, no double quotes, and no lurking Java syntax.

bull; 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.

bull; 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.

SOURCE OF JSP

The 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 dont 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 Servlets Job

Servlets are Java programs that run on Web or application servers, a

剩余内容已隐藏,支付完成后下载完整资料


JSP的技术发展史

Servlet和jsp技术的综述

作者:Kathy Sierra, Bert Bates, Nagle Wiegly

来源:servletamp;jsp

摘要:servlet程序运行在服务器端,与传统的CGI和许多其他类似CGI的技术相比,java servlet动态生成的页面具有更高的效率,更容易使用,功能更强大的特点,并且有更好的可移植性,更节省投资。

Java server pages(jsp)是一种基于web的脚本编程技术,类似于网景公司的服务器端java脚本语言——server-side javascript(ssjs)和微软的active server pages(asp)。与ssjs和asp相比,JSP具有更好的可扩展性,并且它不专属于任何一家厂商或某一特定的Web服务器。尽管JSP规范是由Sun公司制定的,但任何厂商都可以在自己的系统上实现JSP。

关键字:jsp 技术;servlet;http server

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标签。

3:可以对开发团队进行划分。Java程序员可以致力于动态代码。Web开发人员可以将经理集中在表示层上。对于大型的项目,这种划分极为重要。依据开发团队的大小,及项目的复杂程度,可以对静态HTML和动态内容进行弱分离和强分离。

此处的讨论并不是说人们应该放弃使用servlet而仅仅使用JSP。事实上,几乎所有的项目都会同时用到这两种技术。在某些项目中,更适宜选用servlet,而针对项目中的某些请求,我们可能会在MVC构架下组合使用这两项技术。我们总是希望用适当的工具完成相对应的工作,仅仅是servlet并不一定能够胜任所有工作。

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。

  1. Servlet的功能

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

图1-1 网页的中间角色

3.1 读取客户端发送的显式数据。

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

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

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

    1. 生成结果。

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

    1. 向客户发送显式数据(即文档)。

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

    1. 发送隐式的HTTP响应数据。

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

4 动态构建网页的原因

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

4.1 网页基于客户发送的数据。

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

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

如果页面需要根据每个具体的请求做出相应的改变,当然需要在请求发生时构建响应。但是,如果页面周期性地改变,我们可以用两种方式来处理它:周期性地在服务器上构建新的页面(和客户请求无关),或者仅仅在用户请求该页面时再构建。具体应该采用哪种方式要根据具体情况而定,但后一种方式常常更为方便,因为它只需简单地等待用户的请求。例如,天气预报或新闻网站可能会动态地构建页面,也有可能会返回之前构建的页面(如果它还是最新的话)。

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

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

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

  1. Servlet相对于“传统”CGI的优点

和传统CGI及许多类CGI技术相比,Java servlet更高效、更易用、更强大、更容易移植、更安全、也更廉价。

5.1 高效

应用传统的CGI,针对每个HTTP请求都用启动一个新的进程。如果CGI程序自身相对比较简短,那么启动进程的开销会占用大部分执行时间。而使用servlet,Java虚拟机会一直运行,并用轻量级的Java线程处理每个请求,而非重量级的操作系统进程。类似地,应用传统的CGI技术,如果存在对同一CGI程序的N个请求,那么CGI程序的代码会载入内存N次。同样的情况,如果使用servlet,则启动N个线程,但是仅仅载入servlet类的单一副本。这种方式减少了服务器的内存需求,通过实例化更少的对象从而节省了时间。最后,当CGI程序结束对请求的处理之后,程序结束。这种方式难以缓存计算结果,保持数据库连接打开,或是执行依靠持续性数据的其他优化。然而,servlet会一直停留在内存中(即使请求处理完毕),因而可以直接存储客户请求之间的任意复杂数据。

    1. 便利

Servlet提供大量的基础构造,可以自动分析和解码HTML的表单数据,读取和设置HTTP报头,处理cookie,跟踪会话,以及其他此类高级功能。而在CGI中,大部分工作都需要我们资金完成。另外,如果您已经了解了Java编程语言,为什么还有学校Perl呢?您已经承认应用Java技术编写的代码要比Visual Basic,VBScript或C++编写的代码更可靠,且更易重用,为什么还有倒退回去选择那些语言来开发服务器端的程序呢?

5.3强大

Servlet支持常规CGI难以实现或根本不能实现的几项功能。Servlet能够直接于Web服务器对话,而常规的CGI程序做不到这一点,至少在不使用服务器专有API的情况下是这样。例如,与Web服务器的通信使得讲相对URL转换成具体的路径名变得更为容易。多个servlet还可以共享数据,从而易于实现数据库连接共享和类似的资源共享优化。Servlet还能维护请求之间的信息,使得诸如会话跟踪和计算结果缓存等技术变得更为简单。

5.4可移植性

Servlet使用Java编程语言,并且遵循标准的API。所有主要的Web服务器。实际上都直接或通过插件支持servlet。因此。为Macromedia JRun编写的servlet,可以不经过任何修改地在Apache Tomcat,Microsoft Internet Information Server,IBM WebSphere,iPlanet Enterprise Serve,Oracle9i AS 或者StrNine WebStar上运行。他们是java2平台企业版的一部分,所以对servlet的支持越来越普遍。

5.5廉价

对于开发用的网站、低容量或中等容量网站的部署,有大量免费或极为廉价的Web服务器可供选择。因此,通过使用servlet和jsp,我们可以从免费或廉价的服务器开始,在项目获得初步成功后,在移植到更高性能或高级管理工具的昂贵的服务器上。这与其他CGI方案形成鲜明的对比,这些CGI方案在初期都需要为购买专利软件包投入大量的资金。

价格和可移植性在某种程度上是相互关联的。例如,Marty记录了所有通过电子邮件向他发送问题的读者的所在国。印度接近列表的顶端,可能仅次于美国。

Marty曾在马尼拉讲授过jsp和servlet培训课程,那儿对servlet和jsp技术抱很大的兴趣。

那么,为什么印度和菲律宾都对这项技术这么感兴趣呢?我们推测答案可能分两部分。首先,这两个国

剩余内容已隐藏,支付完成后下载完整资料


资料编号:[148557],资料为PDF文档或Word文档,PDF文档可免费转换为Word

您需要先支付 30元 才能查看全部内容!立即支付

企业微信

Copyright © 2010-2022 毕业论文网 站点地图