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

 2022-12-19 06:12

An Overview of Servlet and JSP Technology

Jose Alfonso Aguilar,Irene Garrigos,Juan Trujilo

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 introduction

The navigation of shopping website is particularly important. It determines whether the buyer can quickly locate the category of goods he needs to buy, which has a great impact on whether the user experience is good or not.Shopping according to the various aspects of the site ranking, convenient users quickly find their own shopping site, you can shop around, buy cheap goods.

Due to the continuous infiltration of the Internet into our lives in recent years, it has led to unprecedented prosperity of the Internet.There are peoples growing consumer demand, more led to the proliferation of shopping website.In this context, online shopping navigation emerges at the right moment, and online shopping navigation websites are roughly divided into three categories:

The first kind is comprehensive stronger navigation website

The second category is the professional strong price shopping

The third category is the rebate website well-known shopping website

With the popularity of the Internet, online shopping has become a very important means of consumption.Many people cant live without these shopping sites.People can buy almost everything they need in life from these websites.These sites even offer many virtual services for people.

    1. Features
  1. people only need to input the relevant url of shopping website in the browser to start consuming shopping.
  2. I can quickly find the commodities I want to buy according to the classification of commodities on the website
  3. you can also search for relevant goods according to the recommendation function of the website, which greatly enhances the experience of online shopping.
  4. each shopping website has its own clear positioning, people can be very convenient and fast to buy their favorite items.
    1. operation principleStage
  5. - the seller posts the product on the website first.Stage
  6. - the buyer inquires the detailed information of the commodities he wants to purchase through the classification of shopping website.Stage
  7. - the buyer judges the sellers information and commodity information before purchasing the commodity.Stage
  8. - shopping website records and follow-up processing of commodity orders.Stage
  9. - payment certification.Stage
  10. - payment to seller.Stage

(7)- the seller delivers the goods to the buyer through various forms such as logistics.

2 A Servlets 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-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 doesnt speak HTTP or return results in HTML, so the Web browser cant 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.

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.

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.

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

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

For instance,

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


Servlet和JSP技术概述

Jose Alfonso Aguilar,Irene Garrigos,Juan Trujilo

摘要:Servlet程序运行在服务器端,动态生成的网页与传统CGI等许多类似的CGI技术相比,Java Servlet具有更高效、更容易使用、更强大和具有更好的可移植性,节省了更多的投资。

关键字:JSP技术,Servlet, HTTP server

1引言

购物网站的导航尤为中要,它决定了买家能否快速定位到自己所需要购买的商品类别,对用户的体验是否良好有非常大的影响。根据购物网站的各个方面进行排行,方便网友们快速找到自已购物所需要的网站,可以货比三家,买到物美价廉的商品。

由于最近几年网络不停的渗透进我们的生活,导致了互联网空前繁荣。还有人们日益增长的消费需求,更加导致了购物网站的激增。在这种大背景下网购导航应运而生,而网购导航网站也大致分为3类:

第一类是综合性较强导航网站

第二类是专业性较强的比价购物

第三类是返利网站 知名购物网站

随着互联网的普及,网购已经成了网民很重要的消费手段。许多人的日常生活已经离不开这些购物网站。人们可以从这些网站里买到生活中几乎所有需要的商品。这些网站甚至能为人们提供许多的虚拟服务。

1.1特色

(1)人们只需要在浏览器上输入购物网站的相关网址就可以开始进行消费购物。

(2)可以根据网站对商品的分类划分,非常迅速方面的找到自己想要买的商品。

(3)还可以根据网站的推荐功能查找相关商品,极大的增强了网购的体验。

(4)每个购物网站都有自己明确的定位,人们可以十分方便快捷的买到自己心仪的物品。

1.2运作原理

阶段(1)-卖家先将商品发布到网站上。

阶段(2)-买方通过购物网站的分类查询自己想要购买的商品的详细资料与信息。

阶段(3)-买方通过对卖家信息和商品信息进行判断,再购买商品。

阶段(4)-购物网站对商品订单进行记录以及后续跟踪处理。

阶段(5)-付款认证。

阶段(6)-付款给卖方。

阶段(7)-卖家通过物流等各种形式将货品发送给买家。

2 Servlet的工作

servlet是运行在Web或应用服务器上的Java程序,充当来自Web浏览器或其他HTTP客户机的请求与HTTP服务器上的数据库或应用程序之间的中间层。他们的工作是执行以下任务,如图1-1所示。

图1-1

1、读取客户端发送的显式数据

最终用户通常在Web页面上以HTML表单的形式输入这些数据。不过,数据也可以来自applet或自定义HTTP客户机程序。

2、读取浏览器发送的隐式HTTP请求数据

图1-1显示了一个从客户机到Web服务器(servlet和JSP执行的层)的箭头,但是实际上有两种类型的数据:最终用户以表单形式输入的显式数据和后台HTTP信息。这两个品种都至关重要。HTTP信息包括cookie、关于浏览器能够理解的媒体类型和压缩方案的信息,等等。

3、生成的结果

这个过程可能需要与数据库通信、执行RMI或EJB调用、调用Web服务或直接计算响应。您的实际数据可能在关系数据库中。很好。但是您的数据库可能不会使用HTTP或返回HTML格式的结果,因此Web浏览器不能直接与数据库对话。

即使它可以,出于安全原因,您可能也不希望它这样做。同样的道理也适用于大多数其他应用程序。您需要Web中间层来提取结果在一个文档中。

4、发送显式数据(即,文档)到客户端

这个文档可以以多种格式发送,包括文本(HTML或XML)、二进制(GIF图像),甚至是像gzip这样的压缩格式,它是在其他一些底层格式之上分层的。但是,HTML是目前最常见的格式,所以servlet/JSP的一个重要任务是将结果封装在HTML中。

5、发送隐式HTTP响应数据。

图1-1显示了一个从Web中间层(servlet或JSP页面)到客户机的箭头。但是,实际上发送的数据有两种:文档本身和后台HTTP信息。同样,这两个品种对有效开发都至关重要。发送HTTP响应数据包括告诉浏览器或其他客户机正在返回什么类型的文档(例如HTML)、设置cookie和缓存参数,以及其他类似的任务。

3为什么要动态构建Web页面?

许多客户机请求都可以通过预构建的文档来满足,服务器将在不调用servlet的情况下处理这些请求。然而,在许多情况下,静态结果是不够的,需要为每个请求生成一个页面。Web页面需要即时构建的原因有很多:

1、Web页面基于客户机发送的数据。

例如,搜索引擎的结果页面和在线商店的订单确认页面是特定于特定用户请求的。在读取用户提交的数据之前,您不知道显示什么。只需记住,用户提交两种类型的数据:显式的(即, HTML表单数据)和隐式(即, HTTP请求头)。这两种输入都可以用来构建输出页面。特别是,基于cookie值构建特定于用户的页面是非常常见的。

2、Web页面由频繁变化的数据派生而来。

如果页面对每个请求都进行了更改,那么您当然需要在请求时构建响应。但是,如果它只是周期性地更改,您可以通过两种方式来实现:您可以周期性地在服务器上构建一个新的Web页面(独立于客户机请求),或者您可以等待并只在用户请求时构建页面。正确的方法取决于具体情况,但有时后者更方便:等待用户请求。例如,天气报告或新闻标题站点可能动态构建页面,如果页面仍然是最新的,则可能返回以前构建的页面。

3、该Web页面使用来自公司数据库或其他服务器端源的信息。

如果信息在数据库中,即使客户端使用动态Web内容(如applet),也需要服务器端处理。想象一下,在搜索引擎站点上单独使用applet:

“正在下载50tb的applet,请稍候!”显然,这是愚蠢的;您需要与数据库对话。从客户机到Web层再到数据库(一种三层方法),而不是从applet直接到数据库(一种两层方法),提供了更大的灵活性和安全性,几乎没有性能损失。毕竟,数据库调用通常是限制速率的步骤,所以通过Web服务器不会减慢速度。实际上,三层方法通常更快,因为中间层可以执行缓存和连接池。

原则上,servlet不限于处理HTTP请求的Web或应用程序服务器,还可以用于其他类型的服务器。例如,servlet可以嵌入到FTP或邮件服务器中,以扩展它们的功能。而且,最近标准化了用于SIP(会话启动协议)服务器的servlet API(参见http://jcp.org/en/jsr/detail?id=116)。然而,在实践中,这种servlet的使用并没有流行起来,我们只讨论HTTP servlet。

4功能强大servlet支持一些用常规CGI难以或不可能实现的功能

与传统CGI和许多类似CGI的替代技术相比,Java servlet更高效、更容易使用、更强大、更便携、更安全、更便宜。

1、有效使用传统CGI,将为每个HTTP请求启动一个新进程

如果CGI程序本身相对较短,则启动进程的开销可能会控制执行时间。使用servlet, Java虚拟机保持运行,并使用轻量级Java线程(而不是重量级操作系统进程)处理每个请求。同样,在传统的CGI中,如果对同一个CGI程序有N个请求,那么CGI程序的代码将被加载到内存N次。但是,对于servlet,将有N个线程,但是只加载servlet类的一个副本。这种方法通过实例化更少的对象来减少服务器内存需求和节省时间。最后,当CGI程序完成处理请求时,程序将终止。这种方法使缓存计算、保持数据库连接打开以及执行其他依赖于持久数据的优化变得困难。然而,servlet即使在完成响应之后仍然保留在内存中,因此在客户机请求之间存储任意复杂的数据是很简单的。

2、方便

servlet具有广泛的自动解析和解码HTML表单数据、读取和设置HTTP头文件、处理cookie、跟踪会话以及许多其他高级实用程序。在CGI中,你必须自己完成这些工作。此外,如果您已经了解Java编程语言,为什么还要学习Perl呢?您已经确信Java技术比Visual Basic、VBScript或c 更可靠、更可重用。为什么要回到这些语言来进行服务器端编程呢?

  1. 功能强大

servlet支持一些用常规CGI难以或不可能实现的功能。servlet可以直接与Web服务器通信,而常规CGI程序不能,至少在不使用特定于服务器的API的情况下不能。例如,与Web服务器通信可以更容易地将相对url转换为具体的路径名称。多个servlet还可以共享数据,从而很容易实现数据库连接池和类似的资源共享优化。servlet还可以维护请求之间的信息,从而简化了会话跟踪和缓存以前计算的技术。

  1. 便携式

servlet是用Java编程语言编写的,并遵循标准API。实际上,每个主要Web服务器上都直接或由插件支持servlet。因此,例如,为Macromedia JRun编写的servlet可以在Apache Tomcat、Microsoft Internet Information Server(带有单独的插件)、IBM WebSphere、iPlanet Enterprise Server、Oracle9i AS或StarNine WebStar上几乎不加更改地运行。它们是Java 2平台Enterprise Edition (J2EE;参见http://java.sun.com/j2ee/),因此对servlet的行业支持变得更加普遍。

  1. 便宜

许多免费或非常便宜的Web服务器非常适合开发、使用或部署低容量或中等容量的Web站点。因此,使用servlet和JSP,您可以从一个免费或廉价的服务器开始,并迁移到更昂贵的服务器上,只有在您的项目获得初步成功之后,才能迁移到具有高性能功能或高级管理实用程序的服务器上。这与许多其他CGI替代方案形成了对比,这些替代方案需要购买专有包的大量初始投资。价格和可移植性是有一定联系的。例如,Marty试图跟踪通过电子邮件向他发送问题的读者的国家。马蒂还在马尼拉教授他的一个JSP和servlet培训课程(参见http://courses.coreservlets.com/),那里对servlet和JSP技术非常感兴趣。为什么印度和菲律宾都这么感兴趣呢?我们推测答案是双重的。首先,两国都拥有大量受过良好教育的软件开发人员。第二,这两个国家对美元的货币汇率都非常不利。因此,从美国公司购买专用Web服务器消耗了早期项目资金的很大一部分。但是,对于servlet和JSP,它们可以从一个免费的服务器开始:Apache Tomcat(独立的,嵌入到常规Apache Web服务器中,或者嵌入到Microsoft IIS中)。一旦项目开始成功,他们就可以转移到像Caucho Resin这样的服务器上,该服务器具有更高的性能和更简单的管理,但这不是免费的。但是它们的servlet或JSP页面都不需要重写。如果他们的项目变得更大,他们可能希望迁移到分布式(集群)环境。没问题:他们可以迁移到Macromedia JRun Professional,它支持分布式应用程序(Web farm)。同样,它们的servlet或JSP页面都不需要重写。如果项目变得非常大且复杂,他们可能想要使用Enterprise javabean (EJB)来封装他们的业务逻辑。因此,他们可能会切换到BEA WebLogic或Oracle9i AS。同样,它们的servlet或JSP页面都不需要重写。最后,如果他们的项目变得更大,他们可能会将其从Linux机器上转移到运行IBM WebSphere的IBM大型机上。但是同样,它们的servlet或JSP页面都不需要重写。

6、安全

传统CGI漏洞的一个主要来源是程序通常由通用操作系统shell执行。因此,CGI程序员必须小心地过滤掉shell特殊处理的字符,比如反引号和分号。实现这种预防措施比人们想象的要困难,而且在广泛使用的CGI库中不断发现由这个问题引起的弱点。问题的第二个来源是一些CGI程序是由语言处理的,这些语言不会自动检查数组或字符串边界。例如,在C和c 中,分配一个100个元素的数组,然后写入第999个“元素”是完全合法的,这实际上是程序内存中的随机部分。因此,忘记执行此检查的程序员会使他们的系统受到故意或意外的缓冲区溢出攻击。servlet没有这些问题。即使servlet执行系统调用(例如,使用运行时)。要调用本地操作系统上的程序,它不使用shell。当然,数组边界检查和其他内存保护特性是Java编程语言的核心部分。

7、主流

有很多好的技术。但是,如果供应商不支持它们,开发人员不知道如何使用它们,它们有什么用呢?Servlet和JSP技术由Apache、Oracle、IBM、Sybase、BEA、Macromedia、Caucho、Sun/iPlanet、New Atlanta、ATG、Fujitsu、Lutris、Silverstream、万维网联盟(W3C)等服务器支持。一些低成本的插件也为Microsoft IIS和Zeus提供了支持。它们运行在Windows、Unix/Linux、MacOS、VMS和IBM大型机操作系统上。它们是Java编程语言中最流行的应用程序。它们可以说是开发中到大型Web

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


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

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

课题毕业论文、文献综述、任务书、外文翻译、程序设计、图纸设计等资料可联系客服协助查找。