登录

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

注册

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

找回密码

  • 获取手机验证码60
  • 找回
毕业论文网 > 外文翻译 > 计算机类 > 物联网工程 > 正文

Servlet和JSP技术简述外文翻译资料

 2021-12-22 10:12  

An Overview of Servlet and JSP Technology
Nagle and Wiegley
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 .
Key words: JSP Technology, Servlet, HTTP server 1.1 A Servlet#39;s Job

JSP JavaServer Pages is initiated by Sun Microsystems, Inc., with many companies to participate in the establishment of a dynamic web page technical standards. JSP technology somewhat similar to ASP technology, it is in the traditional HTML web page document *. htm, *. html to insert the Java programming paragraph Scriptlet and JSP tag tag, thus JSP documents *. jsp.
Using JSP development of the Web application is cross-platform that can run on Linux, is also available for other operating systems.
JSP technology to use the Java programming language prepared by the category of XML tags and scriptlets, to produce dynamic pages package processing logic. Page also visit by tags and scriptlets exist in the services side of the resources of logic. JSP page logic and web page design and display separation, support reusable component-based design, Web-based application development is rapid and easy.
Web server in the face of visits JSP page request, the first implementation of the procedures of, and then together with the results of the implementation of JSP documents in HTML code with the return to the customer. Insert the Java programming operation of the database can be re-oriented websites, in order to achieve the establishment of dynamic pages needed to function.
JSP and Java Servlet, is in the implementation of the server, usually returned to the client is an HTML text, as long as the client browser will be able to visit.
JSP pages from HTML code and Java code embedded in one of the components. The server was in the pages of client requests after the Java code and then will generate the HTML pages to return to the client browser. Java Servlet JSP is the technical foundation and large-scale Web application development needs of Java Servlet and JSP support to complete. JSP with the Java technology easy to use, fully object-oriented, and a platform-independent and secure, mainly for all the characteristics of the Internet.
JavaScript, which is completely distinct from the Java programming language, is normally used to dynamically generate HTML on the client, building parts of the Web page as the browser loads the document. This is a useful capability and does not normally overlap with the capabilities of JSP which runs only on the server. JSP pages still include SCRIPT tags for JavaScript, just as normal HTML pages do. In fact, JSP can even be used to dynamically generate the JavaScript that will be sent to the client. So, JavaScript is not a competing technology; it is a complementary one.It is also possible to use JavaScript on the server, most notably on Sun ONE formerly iPlanet, IIS, and BroadVision servers. However, Java is more powerful, flexible, reliable, and portable.
JSP a recursive acronym for 'JSP: Hypertext Preprocessor' is a free, open-source, HTML-embedded scripting language that is somewhat similar to both ASP and JSP. One advantage of JSP is that the dynamic part is written in Java, which already has an extensive API for networking, database access, distributed objects, and the like, whereas PHP requires learning an entirely new, less widely used language. A second advantage is that JSP is much more widely supported by tool and server vendors than is JSP.Versus Pure Servlets.
JSP doesn#39;t provide any capabilities that couldn#39;t, in principle, be accomplished with servlets. In fact, JSP documents are automatically translated into servlets behind the scenes. But it is more convenient to write and to modify! regular HTML than to use a zillion println statements to generate the HTML. Plus, by separating the presentation from the content, you can put different people on different tasks: your Web page design experts can build the HTML by using familiar tools and either leave places for your servlet programmers to insert the dynamic content or invoke the dynamic content indirectly by means of XML tags.

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-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.
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.
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#39;t speak HTTP or return results in HTML, so the Web browser can#39;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.
4.Send the explicit data i.e., the document to the client.



Servlet和JSP技术简述
Nagle and Wiegley
摘要:Servlet程序在服务器端运行,动态地生成Web页面与传统的CGI和许多其他类似CGI的技术相比,Java Servlet具有更高的效率,更容易使用,功能更强大,具有更好的可移植性,更节省投资。

关键字:JSP技术,Servlet,HTTP服务 1.1Servlet的功能

JSPJavaServer Pages是由Sun Microsystems公司倡导、许多公司参与一起建立的一种动态网页技术标准。JSP技术有点类似ASP技术,它是在传统的网页HTML文件*.htm,*.html中插入Java程序段Scriptlet和JSP标记tag,从而形成JSP文件*.jsp。
用JSP开发的Web应用是跨平台的,即能在Linux下运行,也能在其他操作系统上运行。
JSP技术使用Java编程语言编写类XML的tags和scriptlets,来封装产生动态网页的处理逻辑。网页还能通过tags和scriptlets访问存在于服务端的资源的应用逻辑。JSP将网页逻辑与网页设计和显示分离,支持可重用的基于组件的设计,使基于Web的应用程序的开发变得迅速和容易。
Web服务器在遇到访问JSP网页的请求时,首先执行其中的程序段,然后将执行结果连同JSP文件中的HTML代码一起返回给客户。插入的Java程序段可以操作数据库、重新定向网页等,以实现建立动态网页所需要的功能。
JSP与Java Servlet一样,是在服务器端执行的,通常返回该客户端的就是一个HTML文本,因此客户端只要有浏览器就能浏览。
JSP页面由HTML代码和嵌入其中的Java代码所组成。服务器在页面被客户端请求以后对这些Java代码进行处理,然后将生成的HTML页面返回给客户端的浏览器。Java Servlet 是JSP的技术基础,而且大型的Web应用程序的开发需要Java Servlet和JSP配合才能完成。JSP具备了Java技术的简单易用,完全的面向对象,具有平台无关性且安全可靠,主要面向因特网的所有特点。
JavaScript,这是完全不同于Java的编程语言,通常用于在客户机上动态生成HTML,构建部分的Web页面作为浏览器加载文档。这是一个有用的功能,并且通常与JSP仅运行在服务器上的功能不重叠。JSP页面还包括对JavaScript脚本标签处理,就像正常的HTML页面做的。事实上,JSP甚至可以被用来动态地生成JavaScript,将被发送到客户端。因此,JavaScript并不是一个竞争的技术,它是互补的。还可以使用JavaScript在服务器上,最显著的是在sun一原iPlanet ,IIS,BroadVision服务器。并且,Java将更强大、灵活、可靠、轻便。
JSP递归缩写“JSP:超文本预处理器”是一个免费的、开源的、html嵌入式脚本语言,有点类似于ASP。JSP动态的部分是用Java编写的,它已经有了一个广泛的API,用于网络、数据库访问、分布式对象,等等,而PHP需要学习一种全新的,更少的广泛使用的语言。第二个好处是, 与纯servlet相比,JSP是更广泛的支持,工具和服务器供应商。
JSP提供任何原则上servlet可完成的功能。事实上,在幕后JSP文件会自动翻译成servlet。但是它更方便的写和修改!普通HTML比使用一个庞大的数字println语句来生成HTML。另外,通过将表示从内容,你可以把不同的人分配在不同的任务:你的网页设计专家可以构建HTML通过使用熟悉的工具,你的servlet程序员间接通过XML标签插入动态内容或调用动态内容。

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



图1.1Web中间件的作用
(1) 读取客户发送的显式数据。
最终用户一般在页面的HTML表单中输入这些数据。然而,数据还有可能来自applet或定制的HTTP客户程序。
(2) 读取由浏览器发送的隐式请求数据。
图1.1中显示了一条从客户端到Web服务器的单箭头,但实际上从客户端传送到Web服务器的数据有两种,它们分别为用户在表单中输入的显式数据,以及后台的HTTP信息。两种数据都很重要。HTTP信息包括cookie、浏览器所能识别的媒体类型和压缩模式等。 (3) 生成结果。
这个过程可能需要访问数据库、执行RMI或EJB调用、调用Web服务,或者直接计算得出对应的响应。实际的数据可能存储在关系型数据库中。该数据库可能不理解HTTP,或者不能返回HTML形式的结果,所有Web浏览器不能直接与数据库进行会话。即使它能够做到这一点,为了安全上的考虑,我们也不希望让它这么做。对应大多数其他应用程序,也存在类似的问题。因此,我们需要Web中间层从HTTP流中提取输入数据,与应用程序会话,并将结果嵌入到文档中。 (4) 向客户发送显式数据(即文档)。
这个文档可以用各种格式发送,包括文本(HTML或XML),二进制(GIF图),甚至可以式建立在其他底层格式之上的压缩格式,如gzip。但是,到目前为止,HTML式最常用的格式,故而servelt和JSP的重要任务之一就式将结果包装到HTML中。 (5) 发送隐式的HTTP响应数据。
图1.1中显示了一条从Web中间层到客户端的单箭头。但是,实际发送的数据有两种:文档本身,以及后台的HTTP信息。同样,两种数据对开发来说都式至关重要的。HTTP响应数据的发送过程涉及告知浏览器或其他客户程序所返回文档的类型(如HTML),设置cookie和缓存参数,以及其他类似的任务。 1.2动态构建网页的原因
预先建立的文档可以满足客户的许多请求,服务器无需调用servlet就可以处理这些请求。然而,许多情况下静态的结果不能满足要求,我们需要针对每个请求生成一个页面。实时构建页面的理由有很多种:
1、网页基于客户发送的数据。
例如,搜索引擎生成的页面,以及在线商店的订单确认页面,都要针对特定的用户请求而产生。在没有读取到用户提交的数据之前,我们不知道应该显示什么。要记住,用户提交两种类型的数据:显示(即HTML表单的数据)和隐式(即HTTP请求的报头)。两种输入都可用来构建输出页面。基于cookie值针对具体用户构建页面的情况尤其普遍。
2、页面由频繁改变的数据导出。
如果页面需要根据每个具体的请求做出相应的改变,当然需要在请求发生时构建响应。但是,如果页面周期性地改变,我们可以用两种方式来处理它:周期性地在服务器上构建新的页面(和客户请求无关),或者仅仅在用户请求该页面时再构建。具体应该采用哪种方式要根据具体情况而定,但后一种方式常常更为方便,因为它只需简单地等待用户的请求。例如,天气预报或新闻网站可能会动态地构建页面,也有可能会返回之前构建的页面(如果它还是最新的话)。
3、页面中使用了来自公司数据库或其他数据库断数据源的信息。
如果数据存储在数据库中,那么,即使客户端使用动态Web内容,比如applet,我们依旧需要执行服务器端处理。想象以下,如果一个搜索引擎网站完全使用applet,那么用户将会看到:“正在下载50TB的applet,请等待!”。显然,这样很愚蠢;这种情况下,我们需要与数据库进行会话。从客户端到Web层再到数据库(三层结构),要比从applet直接到数据库(二层结构)更灵活,也更安全,而性能上的损失很少甚至没有。毕竟数据库调用通常是对速度影响最大的步骤,因而,经过中间层可以执行高速缓存和连接共享。
理论上讲,servelt并非只用于处理HTTP请求的Web服务器或应用服务器,它同样可以用于其他类型的服务器。例如,servlet能够嵌入到FTP或邮件服务器中,扩展他们的功能。而且,用于会话启动协议服务器的servlet API最近已经被标准化(参见http://jcp.org/en/jsr/detail?id=116)。但在实践中,servelt的这种用法尚不流行,在此,我们只论述HTTP Servlet。 1.3 Servlet相对于“传统”CGI的优点
和传统CGI及许多类CGI技术相比,Java servelt效率更高、更易用、更强大、更容易移植、更安全、也更廉价。
1、效率
应用传统的CGI,针对每个HTTP请求都用启动一个新的进程。如果CGI程序自身相对比较简短,那么启动进程的开销会占用大部分执行时间。而使用servelt,Java虚拟机会一直运行,并用轻量级的Java线程处理每个请求,而非重量级的操作系统进程。类似地,应用传统的CGI技术,如果存在对同一CGI程序的N个请求,那么CGI程序的代码会载入内存N次。同样的情况,如果使用servlet则启动N个线程,单仅仅载入servlet类的单一副本。这种方式减少了服务器的内存需求,通过实例化更少的对象从而节省了时间。最后,当CGI程序结束对请求的处理之后,程序结束。这种方式难以缓存计算结果,保持数据库连接打开,或是执行依靠持续性数据的其他优化。然而,servelt会一直停留在内存中(即使请求处理完毕),因而可以直接存储客户请求之间的任意复杂数据。
2、便利
Servelt提供大量的基础构造,可以自动分析和解码HTML的表单数据,读取和设置HTTP报头,处理cookie,跟踪会话,以及其他次类高级功能。而在CGI中,大部分工作都需要我们资金完成。另外,如果您已经了解了Java编程语言,为什么还有学校Perl呢?您已经承认应用Java技术编写的代码要比Visual Basic,VBScript或C++编写的代码更可靠,且更易重用,为什么还有倒退回去选择那些语言来开发服务器端的程序呢?
3、强大
Servlet支持常规CGI难以实现或根本不能实现的几项功能。Servlet能够直接于Web服务器对话,而常规的CGI程序做不到这一点,至少在不使用服务器专有API的情况下是这样。例如,与Web服务器的通信使得讲相对URL转换成具体的路径名变得更为容易。多个servelt还可以共享数据,从而易于实现数据库连接共享和类似的资源共享优化。Servelt还能维护请求之间的信息,使得诸如会话跟踪和计算结果缓存等技术变得更为简单。
4、可移植性
Servelt使用Java编程语言,并且遵循标准的API。所有主要的Web服务器。实际上都直接或通过插件支持servlet。因此。为Macromedia JRun编写的servlet,可以不经过任何修改地在Apache Tomcat,Microsoft Internet Information Server,IBM WebSphere 。iPlanet Enterprise Server。Oracle9i AS 或者StrNine WebStar上运行。他们是java2平台企业版的一部分,所以对servlet的支持越来越普遍。
5、廉价
对于开发用的网站、低容量或中等容量网站的部署,有大量免费或极为廉价的Web服务器可供选择。因此,通过使用servelt和jsp,我们可以从免费或廉价的服务器开始,在项目获得初步成功后,在移植到更高性能或高级管理工具的昂贵的服务器上。这与其他CGI方案形成鲜明的对比,这些CGI方案在初期都需要为购买专利软件包投入大量的资金。
价格和可移植性在某种程度上是相互关联的。例如,Marty记录了所有通过电子邮件向他发送问题的读者的所在国。印度接近列表的顶端,可能仅次于美国。Marty曾在马尼拉讲授过jsp和servlet培训课程,那儿对servelt和jsp技术抱很大的兴趣。
那么,为什么印度和菲律宾都对这项技术着呢感兴趣呢?我们推测答案可能分两部分。首先,这两个国家都拥有大量训练有素的软件开发人员。其次,这两个国家的货币对美元的汇率都极为不利。因此,从美国公司那里购买专用Web服务器会消耗掉项目的大部分前期资金。
但是,使用servlet 和JSP,他们能够从免费的服务器开始:Apache Tomcat。项目取得成功之后,他们可以转移到性能更高、管理更容易,但需要付费的服务器。他们的servelt和jsp不需要重写编写。如果他们的项目变得更庞大,他们或许希望转移到分布式环境。没有问题:他们可以转而使用Macromedia JRun Professional,该服务器支持分布式应用。同样,他们的servelt和jsp没有任何部分需要重写。如果项目变得极为庞大,错综复杂,他们或许希望使用Enterprise JavaBeans来封装他们的商业逻辑。因此,他们可以切换到BEA WebLogic或Oracle9i AS。同样,不需要对servlet和jsp做出更改。最后,如果他们的项目变得更庞大,他们或许将他从Linux转移到运行IBM WebSphere的IBM大型机上。他们还是不需要做出任何更改。
6、安全
传统CGI程序中主要的漏洞来源之一就是,CGI程序常常由通过的操作系统外壳来执行。因此,CGI程序必须仔细地过滤掉那些可能被外壳特殊处理的字符,如反引导和分号。实现这项预防措施的难度可能超出我们的想象,在广泛应用的CGI库中,不断发现由这类问题引发的弱点。
问题的第二个来源是,一些CGI程序用不自动检查数组和字符串边界的语言编写而成。例如,在C和C++中,可以分配一个100个元素的数组,然后向第999个“元素“写入数据——实际上是程序内存的随机部分,这完全合法。因而,如果程序员忘记执行这项检查,就会将系统暴露在蓄意或偶然的缓冲区溢出攻击之下。
Servelt不存在这些问题。即使servel

资料编号:[3896]

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

企业微信

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