基于JSP的在线书店销售系统的设计与实现外文文献及翻译样本_第1页
基于JSP的在线书店销售系统的设计与实现外文文献及翻译样本_第2页
基于JSP的在线书店销售系统的设计与实现外文文献及翻译样本_第3页
基于JSP的在线书店销售系统的设计与实现外文文献及翻译样本_第4页
基于JSP的在线书店销售系统的设计与实现外文文献及翻译样本_第5页
已阅读5页,还剩12页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

毕业设计(论文)外文文献翻译专业学生姓名班级学号指引教师外文资料名称:AnOverviewofServletandJSPTechnology外文资料出处:Internet附件:1.外文资料翻译译文2.外文原文指引教师评语:签名:年月日Servlet和JSP技术简述NagleandWiegleyXX译摘要:Servlet程序在服务器端运营,动态地生成Web页面与老式CGI和许多其她类似CGI技术相比,JavaServlet具备更高效率,更容易使用,功能更强大,具备更好可移植性,更节约投资。核心字:JSP技术,Servlet,HTTP服务1.1Servlet功能Servlets是运营在Web或应用服务器上Java程序,它是一种中间层,负责连接来自Web浏览器或其她HTTP客户程序祈求和HTTP服务器上数据库或应用程序。Servlet工作是执行西门任务,如图1.1所示。图1.1Web中间件作用读取客户发送显式数据。最后顾客普通在页面HTML表单中输入这些数据。然而,数据尚有也许来自applet或定制HTTP客户程序。读取由浏览器发送隐式祈求数据。图1.1中显示了一条从客户端到Web服务器单箭头,但事实上从客户端传送到Web服务器数据有两种,它们分别为顾客在表单中输入显式数据,以及后台HTTP信息。两种数据都很重要。HTTP信息涉及cookie、浏览器所能辨认媒体类型和压缩模式等。生成成果。这个过程也许需要访问数据库、执行RMI或EJB调用、调用Web服务,或者直接计算得出相应响应。实际数据也许存储在关系型数据库中。该数据库也许不理解HTTP,或者不能返回HTML形式成果,所有Web浏览器不能直接与数据库进行会话。虽然它可以做到这一点,为了安全上考虑,咱们也不但愿让它这样做。相应大多数其她应用程序,也存在类似问题。因而,咱们需要Web中间层从HTTP流中提取输入数据,与应用程序会话,并将成果嵌入到文档中。向客户发送显式数据(即文档)。这个文档可以用各种格式发送,涉及文本(HTML或XML),二进制(GIF图),甚至可以式建立在其她底层格式之上压缩格式,如gzip。但是,到当前为止,HTML式最惯用格式,故而servelt和JSP重要任务之一就式将成果包装到HTML中。发送隐式HTTP响应数据。图1.1中显示了一条从Web中间层到客户端单箭头。但是,实际发送数据有两种:文档自身,以及后台HTTP信息。同样,两种数据对开发来说都式至关重要。HTTP响应数据发送过程涉及告知浏览器或其她客户程序所返回文档类型(如HTML),设立cookie和缓存参数,以及其她类似任务。1.2动态构建网页因素预先建立文档可以满足客户许多祈求,服务器无需调用servlet就可以解决这些祈求。然而,许多状况下静态成果不能满足规定,咱们需要针对每个祈求生成一种页面。实时构建页面理由有诸各种:1、网页基于客户发送数据。例如,搜索引擎生成页面,以及在线商店订单确认页面,都要针对特定顾客祈求而产生。在没有读取到顾客提交数据之前,咱们不懂得应当显示什么。要记住,顾客提交两种类型数据:显示(即HTML表单数据)和隐式(即HTTP祈求报头)。两种输入都可用来构建输出页面。基于cookie值针对详细顾客构建页面状况特别普遍。2、页面由频繁变化数据导出。如果页面需要依照每个详细祈求做出相应变化,固然需要在祈求发生时构建响应。但是,如果页面周期性地变化,咱们可以用两种方式来解决它:周期性地在服务器上构建新页面(和客户祈求无关),或者仅仅在顾客祈求该页面时再构建。详细应当采用哪种方式要依照详细状况而定,但后一种方式经常更为以便,由于它只需简朴地等待顾客祈求。例如,天气预报或新闻网站也许会动态地构建页面,也有也许会返回之前构建页面(如果它还是最新话)。3、页面中使用了来自公司数据库或其她数据库断数据源信息。如果数据存储在数据库中,那么,虽然客户端使用动态Web内容,例如applet,咱们仍旧需要执行服务器端解决。想象如下,如果一种搜索引擎网站完全使用applet,那么顾客将会看到:“正在下载50TBapplet,请等待!”。显然,这样很愚蠢;这种状况下,咱们需要与数据库进行会话。从客户端到Web层再到数据库(三层构造),要比从applet直接到数据库(二层构造)更灵活,也更安全,而性能上损失很少甚至没有。毕竟数据库调用普通是对速度影响最大环节,因而,通过中间层可以执行高速缓存和连接共享。理论上讲,servelt并非只用于解决HTTP祈求Web服务器或应用服务器,它同样可以用于其她类型服务器。例如,servlet可以嵌入到FTP或邮件服务器中,扩展她们功能。并且,用于会话启动合同服务器servletAPI近来已经被原则化(参见)。但在实践中,servelt这种用法尚不流行,在此,咱们只阐述HTTPServlet。1.3Servlet相对于“老式”CGI长处和老式CGI及许多类CGI技术相比,Javaservelt效率更高、更易用、更强大、更容易移植、更安全、也更便宜。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技术编写代码要比VisualBasic,VBScript或C++编写代码更可靠,且更易重用,为什么尚有倒退回去选取那些语言来开发服务器端程序呢?3、强大Servlet支持常规CGI难以实现或主线不能实现几项功能。Servlet可以直接于Web服务器对话,而常规CGI程序做不到这一点,至少在不使用服务器专有API状况下是这样。例如,与Web服务器通信使得讲相对URL转换成详细途径名变得更为容易。各种servelt还可以共享数据,从而易于实现数据库连接共享和类似资源共享优化。Servelt还能维护祈求之间信息,使得诸如会话跟踪和计算成果缓存等技术变得更为简朴。4、可移植性Servelt使用Java编程语言,并且遵循原则API。所有重要Web服务器。事实上都直接或通过插件支持servlet。因而。为MacromediaJRun编写servlet,可以不通过任何修改地在ApacheTomcat,MicrosoftInternetInformationServer,IBMWebSphere。iPlanetEnterpriseServer。Oracle9iAS或者StrNineWebStar上运营。她们是java2平台公司版一某些,因此对servlet支持越来越普遍。5、便宜对于开发用网站、低容量或中档容量网站布置,有大量免费或极为便宜Web服务器可供选取。因而,通过使用servelt和jsp,咱们可以从免费或便宜服务器开始,在项目获得初步成功后,在移植到更高性能或高档管理工具昂贵服务器上。这与其她CGI方案形成鲜明对比,这些CGI方案在初期都需要为购买专利软件包投入大量资金。价格和可移植性在某种限度上是互有关联。例如,Marty记录了所有通过电子邮件向她发送问题读者所在国。印度接近列表顶端,也许仅次于美国。Marty曾在马尼拉讲授过jsp和servlet培训课程,那儿对servelt和jsp技术抱很大兴趣。那么,为什么印度和菲律宾都对这项技术着呢感兴趣呢?咱们推测答案也许分两某些。一方面,这两个国家都拥有大量训练有素软件开发人员。另一方面,这两个国家货币对美元汇率都极为不利。因而,从美国公司那里购买专用Web服务器会消耗掉项目大某些前期资金。但是,使用servlet和JSP,她们可以从免费服务器开始:ApacheTomcat。项目获得成功之后,她们可以转移到性能更高、管理更容易,但需要付费服务器。她们servelt和jsp不需要重写编写。如果她们项目变得更庞大,她们或许但愿转移到分布式环境。没有问题:她们可以转而使用MacromediaJRunProfessional,该服务器支持分布式应用。同样,她们servelt和jsp没有任何某些需要重写。如果项目变得极为庞大,错综复杂,她们或许但愿使用EnterpriseJavaBeans来封装她们商业逻辑。因而,她们可以切换到BEAWebLogic或Oracle9iAS。同样,不需要对servlet和jsp做出更改。最后,如果她们项目变得更庞大,她们或许将她从Linux转移到运营IBMWebSphereIBM大型机上。她们还是不需要做出任何更改。6、安全老式CGI程序中重要漏洞来源之一就是,CGI程序经常由通过操作系统外壳来执行。因而,CGI程序必要仔细地过滤掉那些也许被外壳特殊解决字符,如反引导和分号。实现这项防止办法难度也许超过咱们想象,在广泛应用CGI库中,不断发现由此类问题引起弱点。问题第二个来源是,某些CGI程序用不自动检查数组和字符串边界语言编写而成。例如,在C和C++中,可以分派一种100个元素数组,然后向第999个“元素“写入数据——事实上是程序内存随机某些,这完全合法。因而,如果程序员忘掉执行这项检查,就会将系统暴露在蓄意或偶尔缓冲区溢出袭击之下。Servelt不存在这些问题。虽然servelt执行系统调用激活本地操作系统上程序,它也不会用到外壳来完毕这项任务。固然,数组边界检查以及其她内存包括特性是java编程语言核心某些。7、主流虽然存在许多较好技术,但是,如果提供商助支持她们,或开发人员不懂得如何使用这些技术,那么它们长处又如何体现呢?servelt和jsp技术得到服务器提供商广泛支持,涉及Apache,Oracle,IBM,Sybase,BEA,Maromedia,Causho,Sun/iPlanet,NewAtlanta,ATG,Fujitsu,Lutris,Silverstream,WorldWideWebConsortinrm,以及其她服务器。存在几种低廉插件,通过应用这些插件,MicrosoftIIS和Zeus也同样支持servlet和jsp技术,它们运营在Windows,Unix/Linus,MacOS,VMS,和IBM大型机操作系统之上。它们用在航空业、电子商务、在线银行、web搜索引擎、门户、大型金融网站、以及成百上千您寻常光顾其她网站。固然,仅仅是流行并不能证明技术优越性。诸多泛美例子。但咱们立场是:服务器端Java本非一项新、为经证明技术。

AnOverviewofServletandJSPTechnologyNagleandWiegleyAbstract:Servletprogramrunningintheserver-side,dynamicallygeneratedWebpagewiththetraditionalCGIandmanyothersimilarcomparedtoCGItechnology,JavaServletwithamoreefficient,easiertouse,morepowerfulandhasbetterportability,moresavingstoinvest.Keywords:JSPTechnology,Servlet,HTTPserver1.1AServlet'sJobServletsareJavaprogramsthatrunonWeborapplicationservers,actingasamiddlelayerbetweenrequestscomingfromWebbrowsersorotherHTTPclientsanddatabasesorapplicationsontheHTTPserver.Theirjobistoperformthefollowingtasks,asillustratedinFigure1-1.Figure1-11.Readtheexplicitdatasentbytheclient.TheendusernormallyentersthisdatainanHTMLformonaWebpage.However,thedatacouldalsocomefromanappletoracustomHTTPclientprogram.2.ReadtheimplicitHTTPrequestdatasentbythebrowser.Figure1-1showsasinglearrowgoingfromtheclienttotheWebserver(thelayerwhereservletsandJSPexecute),buttherearereallytwovarietiesofdata:theexplicitdatathattheenduserentersinaformandthebehind-the-scenesHTTPinformation.Bothvarietiesarecritical.TheHTTPinformationincludescookies,informationaboutmediatypesandcompressionschemesthebrowserunderstands,andsoon.3.Generatetheresults.Thisprocessmayrequiretalkingtoadatabase,executinganRMIorEJBcall,invokingaWebservice,orcomputingtheresponsedirectly.Yourrealdatamaybeinarelationaldatabase.Fine.Butyourdatabaseprobablydoesn'tspeakHTTPorreturnresultsinHTML,sotheWebbrowsercan'ttalkdirectlytothedatabase.Evenifitcould,forsecurityreasons,youprobablywouldnotwantitto.Thesameargumentappliestomostotherapplications.YouneedtheWebmiddlelayertoextracttheresultsinsideadocument.4.Sendtheexplicitdata(i.e.,thedocument)totheclient.Thisdocumentcanbesentinavarietyofformats,includingtext(HTMLorXML),binary(GIFimages),orevenacompressedformatlikegzipthatislayeredontopofsomeotherunderlyingformat.But,HTMLisbyfarthemostcommonformat,soanimportantservlet/JSPtaskistowraptheresultsinsideofHTML.5.SendtheimplicitHTTPresponsedata.Figure1-1showsasinglearrowgoingfromtheWebmiddlelayer(theservletorJSPpage)totheclient.But,therearereallytwovarietiesofdatasent:thedocumentitselfandthebehind-the-scenesHTTPinformation.Again,bothvarietiesarecriticaltoeffectivedevelopment.SendingHTTPresponsedatainvolvestellingthebrowserorotherclientwhattypeofdocumentisbeingreturned(e.g.,HTML),settingcookiesandcachingparameters,andothersuchtasks.1.2WhyBuildWebPagesDynamically?manyclientrequestscanbesatisfiedbyprebuiltdocuments,andtheserverwouldhandletheserequestswithoutinvokingservlets.Inmanycases,however,astaticresultisnotsufficient,andapageneedstobegeneratedforeachrequest.ThereareanumberofreasonswhyWebpagesneedtobebuilton-the-fly:1.TheWebpageisbasedondatasentbytheclient.Forinstance,theresultspagefromsearchenginesandorder-confirmationpagesatonlinestoresarespecifictoparticularuserrequests.Youdon'tknowwhattodisplayuntilyoureadthedatathattheusersubmits.Justrememberthattheusersubmitstwokindsofdata:explicit(i.e.,HTMLformdata)andimplicit(i.e.,HTTPrequestheaders).Eitherkindofinputcanbeusedtobuildtheoutputpage.Inparticular,itisquitecommontobuildauser-specificpagebasedonacookievalue.2.TheWebpageisderivedfromdatathatchangesfrequently.Ifthepagechangesforeveryrequest,thenyoucertainlyneedtobuildtheresponseatrequesttime.Ifitchangesonlyperiodically,however,youcoulddoittwoways:youcouldperiodicallybuildanewWebpageontheserver(independentlyofclientrequests),oryoucouldwaitandonlybuildthepagewhentheuserrequestsit.Therightapproachdependsonthesituation,butsometimesitismoreconvenienttodothelatter:waitfortheuserrequest.Forexample,aweatherreportornewsheadlinessitemightbuildthepagesdynamically,perhapsreturningapreviouslybuiltpageifthatpageisstilluptodate.3.TheWebpageusesinformationfromcorporatedatabasesorotherserver-sidesources.Iftheinformationisinadatabase,youneedserver-sideprocessingeveniftheclientisusingdynamicWebcontentsuchasanapplet.Imagineusinganappletbyitselfforasearchenginesite:"Downloading50terabyteapplet,pleasewait!"Obviously,thatissilly;youneedtotalktothedatabase.GoingfromtheclienttotheWebtiertothedatabase(athree-tierapproach)insteadoffromanappletdirectlytoadatabase(atwo-tierapproach)providesincreasedflexibilityandsecuritywithlittleornoperformancepenalty.Afterall,thedatabasecallisusuallytherate-limitingstep,sogoingthroughtheWebserverdoesnotslowthingsdown.Infact,athree-tierapproachisoftenfasterbecausethemiddletiercanperformcachingandconnectionpooling.Inprinciple,servletsarenotrestrictedtoWeborapplicationserversthathandleHTTPrequestsbutcanbeusedforothertypesofserversaswell.Forexample,servletscouldbeembeddedinFTPormailserverstoextendtheirfunctionality.And,aservletAPIforSIP(SessionInitiationProtocol)serverswasrecentlystandardized(see).Inpractice,however,thisuseofservletshasnotcaughton,andwe'llonlybediscussingHTTPservlets.1.3TheAdvantagesofServletsOver"Traditional"CGIJavaservletsaremoreefficient,easiertouse,morepowerful,moreportable,safer,andcheaperthantraditionalCGIandmanyalternativeCGI-liketechnologies.1.EfficientWithtraditionalCGI,anewprocessisstartedforeachHTTPrequest.IftheCGIprogramitselfisrelativelyshort,theoverheadofstartingtheprocesscandominatetheexecutiontime.Withservlets,theJavavirtualmachinestaysrunningandhandleseachrequestwithalightweightJavathread,notaheavyweightoperatingsystemprocess.Similarly,intraditionalCGI,ifthereareNrequeststothesameCGIprogram,thecodefortheCGIprogramisloadedintomemoryNtimes.Withservlets,however,therewouldbeNthreads,butonlyasinglecopyoftheservletclasswouldbeloaded.Thisapproachreducesservermemoryrequirementsandsavestimebyinstantiatingfewerobjects.Finally,whenaCGIprogramfinisheshandlingarequest,theprogramterminates.Thisapproachmakesitdifficulttocachecomputations,keepdatabaseconnectionsopen,andperformotheroptimizationsthatrelyonpersistentdata.Servlets,however,remaininmemoryevenaftertheycompletearesponse,soitisstraightforwardtostorearbitrarilycomplexdatabetweenclientrequests.2.ConvenientServletshaveanextensiveinfrastructureforautomaticallyparsinganddecodingHTMLformdata,readingandsettingHTTPheaders,handlingcookies,trackingsessions,andmanyothersuchhigh-levelutilities.InCGI,youhavetodomuchofthisyourself.Besides,ifyoualreadyknowtheJavaprogramminglanguage,whylearnPerltoo?You'realreadyconvincedthatJavatechnologymakesformorereliableandreusablecodethandoesVisualBasic,VBScript,orC++.Whygobacktothoselanguagesforserver-sideprogramming?3.PowerfulServletssupportseveralcapabilitiesthataredifficultorimpossibletoaccomplishwithregularCGI.ServletscantalkdirectlytotheWebserver,whereasregularCGIprogramscannot,atleastnotwithoutusingaserver-specificAPI.CommunicatingwiththeWebservermakesiteasiertotranslaterelativeURLsintoconcretepathnames,forinstance.Multipleservletscanalsosharedata,makingiteasytoimplementdatabaseconnectionpoolingandsimilarresource-sharingoptimizations.Servletscanalsomaintaininformationfromrequesttorequest,simplifyingtechniqueslikesessiontrackingandcachingofpreviouscomputations.4.PortableServletsarewrittenintheJavaprogramminglanguageandfollowastandardAPI.ServletsaresupporteddirectlyorbyapluginonvirtuallyeverymajorWebserver.Consequently,servletswrittenfor,say,MacromediaJRuncanrunvirtuallyunchangedonApacheTomcat,MicrosoftInternetInformationServer(withaseparateplugin),IBMWebSphere,iPlanetEnterpriseServer,Oracle9iAS,orStarNineWebStar.TheyarepartoftheJava2Platform,EnterpriseEdition(J2EE;see),soindustrysupportforservletsisbecomingevenmorepervasive.5.InexpensiveAnumberoffreeorveryinexpensiveWebserversaregoodfordevelopmentuseordeploymentoflow-ormedium-volumeWebsites.Thus,withservletsandJSPyoucanstartwithafreeorinexpensiveserverandmigratetomoreexpensiveserverswithhigh-performancecapabilitiesoradvancedadministrationutilitiesonlyafteryourprojectmeetsinitialsuccess.ThisisincontrasttomanyoftheotherCGIalternatives,whichrequireasignificantinitialinvestmentforthepurchaseofaproprietarypackage.Priceandportabilityaresomewhatconnected.Forexample,Martytriestokeeptrackofthecountriesofreadersthatsendhimquestionsbyemail.Indiawasnearthetopofthelist,probably#2behindtheU.S.MartyalsotaughtoneofhisJSPandservlettrainingcourses(see)inManila,andtherewasgreatinterestinservletandJSPtechnologythere.Now,whyareIndiaandthePhilippinesbothsointerested?Wesurmisethattheansweristwofold.First,bothcountrieshavelargepoolsofwell-educatedsoftwaredevelopers.Second,bothcountrieshave(orhad,atthattime)highlyunfavorablecurrencyexchangeratesagainsttheU.S.dollar.So,buyingaspecial-purposeWebserverfromaU.S.companyconsumedalargepartofearlyprojectfunds.But,withservletsandJSP,theycouldstartwithafreeserver:ApacheTomcat(eitherstandalone,embeddedintheregularApacheWebserver,orembeddedinMicrosoftIIS).Oncetheprojectstartstobecomesuccessful,theycouldmovetoaserverlikeCauchoResinthathadhigherperformanceandeasieradministrationbutthatisnotfree.ButnoneoftheirservletsorJSPpageshavetoberewritten.Iftheirprojectbecomesevenlarger,theymightwanttomovetoadistributed(clustered)environment.Noproblem:theycouldmovetoMacromediaJRunProfessional,whichsupportsdistributedapplications(Webfarms).Again,noneoftheirservletsorJSPpageshavetoberewritten.Iftheprojectbecomesquitelargeandcomplex,theymightwanttouseEnterpriseJavaBeans(EJB)toencapsulatetheirbusinesslogic.So,theymightswitchtoBEAWebLogicorOracle9iAS.Again,noneoftheirservletsorJSPpageshavetoberewritten.Finally,iftheirprojectbecomesevenbigger,theymightmoveitoffoftheirLinuxboxandontoanIBMmainframerunningIBMWebSphere.Butonceagain,noneoftheirservletsorJSPpageshavetoberewritten.6.SecureOneofthemainsourcesofvulnerabilitiesintraditionalCGIstemsfromthefactthattheprogramsareoftenexecutedbygeneral-purposeoperatingsystemshells.So,theCGIprogrammermustbecarefultofilteroutcharacterssuchasbackquotesandsemicolonsthataretreatedspeciallybytheshell.Implementingthisprecautionisharderthanonemightthink,andweaknessesstemmingfromthisproblemareconstantlybeinguncoveredinwidelyusedCGIlibraries.AsecondsourceofproblemsisthefactthatsomeCGIprogramsareprocessedbylanguagesthatdonotautomaticallycheckarrayo

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论