毕业论文外文文献翻译Professional-JSP节选_第1页
毕业论文外文文献翻译Professional-JSP节选_第2页
毕业论文外文文献翻译Professional-JSP节选_第3页
毕业论文外文文献翻译Professional-JSP节选_第4页
毕业论文外文文献翻译Professional-JSP节选_第5页
已阅读5页,还剩9页未读 继续免费阅读

付费下载

下载本文档

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

文档简介

PAGE毕业设计(论文)外文文献翻译文献、资料中文题目:ProfessionalJSP节选文献、资料英文题目:文献、资料来源:文献、资料发表(出版)日期:院(部):专业:班级:姓名:学号:指导教师:翻译日期:2017.02.14外文资料所译外文资料:①作者:DanMalks②书名:ProfessionalJSP③出版时间:2000.7.26④所译章节:Chapter1212.1IntroductoryGoodWebapplicationdesigntriestoseparatebusinessobjects,presentation,andmanipulationoftheobjectsintodistinctlayers.OnebenefitofusingJavaServerPagestechnologyisthatitallowsustoseparatetheroleofaWebdesignermoreclearlyfromthatofasoftwaredeveloper.Whileonasmall-scaleproject,oneindividualmayoccupybothroles,onalargerproject,theyarelikelytobeseparateanditisbeneficialtoseparatetheirworkflowsasmuchaspossible.DesigningthearchitectureforyourWebapplicationiscrucialtothisseparation.12.2JSParchitectureWewillexamineavarietyofwaystoarchitectasystemwithJavaServerPages,servlets,andJavaBeans.Wewillseeaseriesofdifferentarchitectures,eachadevelopmentoftheonebefore.Thediagrambelowshowsthisprocessinoutline;theindividualpartsofthediagramwillbeexplainedinturnlaterinthisarticle.JSParchitecture:WhenSunintroducedJavaServerPages,somewerequicktoclaimthatservletshadbeenreplacedasthepreferredrequesthandlingmechanisminWeb-enabledenterprisearchitectures.AlthoughJSPisakeycomponentoftheJava2PlatformEnterpriseEdition(J2EE)specification,servingasthepreferredrequesthandlerandresponsemechanism,wemustinvestigatefurthertounderstanditsrelationshipwithservlets.OthersectionsofProfessionalJSPexplaintheimplementationdetailsofJSPsourcetranslationandcompilationintoaservlets.UnderstandingthatJSPisbuiltontopoftheservletAPI,andusesservletsemantics,raisessomeinterestingquestions.Shouldwenolongerdevelopstand-aloneservletsinourWeb-enabledsystems?IstheresomewaytocombineservletsandJSPs?Ifso,wheredoweplaceourJavacode?Arethereanyothercomponentsinvolvedintherequestprocessing,suchasJavaBeans?Ifso,wheredotheyfitintothearchitectureandwhattypeofroledotheyfulfill?Itisimportanttounderstandthat,althoughJSPtechnologywillbeapowerfulsuccessortobasicservlets,theyhaveanevolutionaryrelationshipandcanbeusedinacooperativeandcomplementarymanner.Giventhispremise,wewillinvestigatehowthesetwotechnologies,eachaJavaStandardExtension,canbeusedco-operativelyalongwithothercomponents,suchasJavaBeans,tocreateJava-basedWeb-enabledsystems.WewillexaminearchitecturalissuesastheyrelatetoJSPandservletsanddiscusssomeeffectivedesignswhilelookingatthetradeoffsofeach.Beforejumpingdirectlyintoadiscussionofspecificarchitectures,though,wewillbrieflyexaminetheneedtodevelopavarietyofarchitectures.12.3CodefactoringandroleseparationOneofthemainreasonswhytheJavaServerPagestechnologyhasevolvedintowhatitistoday(andit'sstillevolving)istheoverwhelmingtechnicalneedtosimplifyapplicationdesignbyseparatingdynamiccontentfromstatictemplatedisplaydata.ThefoundationforJSPwaslaiddownwiththeinitialdevelopmentoftheJavaWebServerfromSun,whichusedpagecompilationandfocusedonembeddingHTMLinsideJavacode.Asapplicationscametobebasedmoreonbusinessobjectsandn-tierarchitectures,thefocuschangedtoseparatingHTMLfromJavacode,whilestillmaintainingtheintegrityandflexibilitythetechnologyprovided.InChapter5,JSPSessions,inProfessionalJSP,wesawhowbeansandobjectscanbeboundtodifferentcontextsjustbydefiningacertainscope.Goodapplicationdesignbuildsonthisideaandtriestoseparatetheobjects,thepresentation,andthemanipulationoftheobjectsintodistinct,distinguishablelayers.AnotherbenefitofusingJSPisthatitallowsustomorecleanlyseparatetherolesofaWebproduction/HTMLdesignerindividualfromasoftwaredeveloper.RememberthatacommondevelopmentscenariowithservletswastoembedtheHTMLpresentationmarkupwithintheJavacodeoftheservletitself,whichcanbetroublesome.Inourdiscussion,wewillconsidertheservletsolelyasacontainerforJavacode,whileourentireHTMLpresentationtemplateisencapsulatedwithinaJSPsourcepage.ThequestionthenarisesastohowmuchJavacodeshouldremainembeddedwithinourJSPsourcepages,andifitistakenoutoftheJSPsourcepage,whereshoulditreside?Let'sinvestigatethisfurther.OnanyWeb-basedproject,multiplerolesandresponsibilitieswillexist.Forexample,anindividualwhodesignsHTMLpagesfulfillsaWebproductionrolewhilesomeonewhowritessoftwareintheJavaprogramminglanguagefulfillsasoftwaredevelopmentrole.Onsmall-scaleprojectstheserolesmightbefilledbythesameindividual,ortwoindividualsworkingcloselytogether.Onalargerproject,theywilllikelybefilledbymultipleindividuals,whomightnothaveoverlappingskillsets,andarelessproductiveifmadetoodependentontheworkflowoftheother.IfcodethatcouldbefactoredouttoamediatingservletisincludedinsteadwithinHTMLmarkup,thenthepotentialexistsforindividualsinthesoftwaredevelopmentroleandthoseintheWebproductionroletobecomemoredependentthannecessaryontheprogressandworkflowoftheother.Suchdependenciesmaycreateamoreerror-proneenvironment,whereinadvertentchangestocodebyotherteammembersbecomemorecommon.Thisgivesussomeinsightintoonereasonwhywecontinuetodevelopbasicservlets:theyareanappropriatecontainerforourcommonJavacodethathasbeenfactoredoutofourJSPpages,givingoursoftwaredevelopmentteamanareaoffocusthatisaslooselycoupledtoourJSPpagesaspossible.Certainly,therewillbeaneedforthesesameindividualstoworkwiththeJSPsourcepages,butthedependencyisreduced,andthesepagesbecomethefocusoftheWeb-productionteaminstead.Ofcourse,ifthesameindividualfulfillsbothroles,asistypicalonasmallerproject,suchdependenciesarenotamajorconcern.So,weshouldtrytominimizetheJavacodethatweincludewithinourJSPpage,inordertoupholdthiscleanerseparationofdeveloperroles.Aswehavediscussed,someofthisJavacodeisappropriatelyfactoredtoamediatingservlet.Codethatiscommontomultiplerequests,suchasauthentication,isagoodcandidateforamediatingservlet.Suchcodeisincludedinoneplace,theservlet,insteadofpotentiallybeingcutandpastedintomultipleJSPs.WewillalsowanttoremovemuchofourbusinesslogicanddataaccesscodefromourJSPpageandencapsulateitwithinJavaBeans,calledworkerorhelperbeans.WestarttoseeapatternofcodemovementfromourJSPintotwoareas:aservlet(orJSP)thatsitsinfrontofthemainJSP,andJavaBeansthatsitinback.Werefertothiscommonpatternas"FactorForward--FactorBack,"asshowninthefigurebelow:FactorForward--FactorBack:AnotherwaytothinkaboutwhatcodeshouldbelocalizedandencapsulatedisthatourJSPpageshouldrevealaslittleaspossibleofourJavacodeimplementationdetails.Rather,thepageshouldcommunicateourintentbyrevealingthedelegatingmessageswesendtoworkerbeans,instructingthemtogetstatefromamodel,ortocompletesomebusinessprocessing.12.4RedirectingandforwardingRedirectingandforwardingrequestsinJSPsandservletstakesplaceoften,anditisimportanttounderstandthesubtledifferencebetweenthesetwomechanismseventhoughtheyachievethesamegoal(thatis,aclientasksforaresourceontheserverandadifferentresourceisservedtoit):WhenaservletorJSPresourcechoosestoredirecttheclient(usingaresponse.sendRedirect(url))therequestobjectdoesnotreachthesecondresourcedirectlysincetheunderlyingimplementationisanHTTPredirect.TheserversendsanHTTP302messagebacktotheclienttellingitthattheresourcehasmovedtoanotherURL,andthattheclientshouldaccessitthere.ThebottomlineisthatthelifecycleoftheinitialrequestobjectthatwasaccessedinthefirstJSPterminateswiththeendoftheservicemethodinthefirstJSP,orwiththereplyfromtheserver.Inaforwardmechanismtherequestobjectisforwardedtothesecondresource,thusmaintaininganyobjectbindingstotherequestanditsstate,withoutaroundtriptotheclientonthenetwork.ThisallowsthefirstJSPtodosomeworkinternallyandthensendinformationtothesecondJSPaskingittodoitsbit.(Servletsusedachainingmechanismtodothis).SeeChapter5,JSPSessions,inProfessionalJSPtogetaclearerpictureofscope.JSPsandservletscanusetheforwardingmechanismtodelegatetasksamongthemselves,intheprocessofseparatingdynamicandstaticcontent.Now,let'sinvestigatehowwebuildthesesystems.12.5ArchitecturesBeforediscussingspecificarchitecturesthatwecanusetobuildsystemswithservletsandJSP,itisworthmentioningtwobasicwaysofusingtheJSPtechnology.Eachofthearchitecturesdiscussedinthischapterwillbebasedononeoftheseapproaches:Thefirstmethodisreferredtohereasthecentric(orclient-server)approach.ThisapproachinvolvesrequestinvocationsbeingmadedirectlytoJSPpage.Inthesecondmethod,thedispatcher(orn-tier)approach,abasicservletorJSPactsasamediatororcontroller,delegatingrequeststoJSPpagesandJavaBeans.Wewillexaminetheseapproachesinlightofasimpleexample,whichwillevolvetosatisfytherequirementsofvariousscenarios.TheinitialscenarioinvolvesprovidingaWebinterfaceforguessingstatisticsaboutasoon-to-be-bornbaby.Theguessesarestored,andcanbereviewedlaterbytheparents,toseewhohasguessedtheclosest.Astherequirementscenariosbecomemoresophisticated,suchasaddingthedesireforapersistencemechanism,thesolutionscenarioswillbecomemoresophisticated,aswell.Thus,ourexamplewillevolveandwewillgainanunderstandingofhowthevariousarchitecturesthatwediscusswillhelpusbuildasystemthatsatisfiestheserequirementsinanelegantandeffectivemanner.12.6ThecentricapproachApplicationsbuiltusingaclient-serverapproachhavebeenaroundforsometime;theyconsistofoneormoreapplicationprogramsrunningonclientmachinesandconnectingtoaserver-basedapplicationtowork.(AgoodexamplewouldbeaPowerBuilderorOracleForms-basedsystem.)CGIsandpre-servletapplicationsweregenerallybasedonthissimple2-tiermodel,andwiththeintroductionofservlets,2-tierapplicationscouldalsobecreatedinJava.ThismodelallowsJSPsorservletsdirectaccesstosomeresourcelikeadatabaseorlegacyapplicationtoserviceaclient'srequest:theearlyJSPspecificationstermedthisa"Model1"programmingapproach.TheJSPpageiswheretheincomingrequestisinterceptedandprocessed,andtheresponseissentbacktotheclient;JSPsonlydifferedfromservletsinthisscenariobyprovidingcleanercodeandseparatingcodefromthecontentbyplacingdataaccessinbeans.Model1programmingapproach:Theadvantageofsuchanapproachisthatitissipletoprogram,andallowsthepageauthortoGeneratedynamiccontenteasily,basedupontherequestandthestateresources.Howeverthisarchitecturedoesnotscaleupwellforalargenumberofsimultaneousclientssincetherewouldbeasignificantamountofrequestprocessingtobeperformed,andeachrequestmustestablishorshareapotentiallyscarce/expensiveconnectiontotheresourceinquestion.(AgoodexamplewouldbeJDBCconnectonsinservletsorJSPsandtheneedforconnectionpools.)IndiscriminateusageofthisarchitectureusuallyleadstoasignificantamountofJavacodeembeddedwithintheJSPpage,thismaynotseemtobemuchofaproblemforJavadevelopersbutitiscertainlyanissueiftheJSPpagesaremaintainedbydesigners:thecodetendstogetinthedesigne’sway,andyouruntheriskofyourcodebecomingcorruptedwhenothersaretweakingthelookandfeel.译文12.1前言好的Web应用设计试图将业务对象,简报以及操作对象分为不同的层面。采用JSP技术的一个好处在于它使我们更清楚地把Web设计者的作用从一个软件开发商中分离出来。在小规项目中,单个体可能担任着着两个角色,在较大的项目中,他们可能被分开,尽可能地分开他们的工作流程是有好处的,比如有利于自己的工作流程,且你的Web应用设计结构对这种分离是至关重要的。12.2JSP的结构我们将研究采取各种方式来设计利用关于JSP的结构层次,还有Servlets以及JavaBeans技术。我们将看到一系列不同的结构,一个一个地形成。下面的图示显示了这一过程,个别图示将于稍后在这篇文章中作了解释。JSP的结构图:当Sun公司引进使用JSP时,一些人连忙声称JSP己经取代Servlet机制成为网络结构中处理机制的首选。虽然JSP是Java2平台企业版规格的核心部分,但作为首选的管理者和反应机制,我们必须进一步调查,了解JSP与Servlets这间的关系。本书的其它部分解释了JSP将原始资料编译和汇编成Servlet的执行细节。JSP的理解是建立在ServletAPI的高层基础上,并使用Servlet语义,引起一些有趣的问题。难道我们就不能在我们的网络使用系统中发展自成一体的Servlet吗?还有办法结合Servlets和JSPs吗?若如些,我们将如何设置Java代码?还有其它部分参与了请求处理,就像JavaBeans?若如此的话,它们是如何融入结构,它们又是充当一个什么样的角色。必须认识到,尽管JSP技术将会成为基础Servlets的有力后继,但是他们有一个渐进的关系,并且可以在合作与互补的方式下使用,认识这一点,是很重要的。在这个前提下,我们要探讨研究这两种技术,每一个Java标准扩展,是如何与其它部分联合使用,如JavaBeans技术,是用来创造一个Java为基础的Web驱动系统。我们要调查研究涉及到JSP和Servlet的结构问题,并在对其权衡的同时讨论一些有效的设计。但是,在直接跳入讨论这特别结构之前,我们要简要研究发展结构多样性的必要性。12.3编程要素和角色分离为什么JSP的技术演变成今天的样子(它一直在演变发展)的一个重要原因是对通过从静态演示数据中分离动态展示数据来简化设计的技术需求很大。随着来自Sun公司的JSP的初步发展,JSP的基础得到了初步奠定,它使用于网页汇编并注重将页内的HTML嵌入Java的代码中。因为申请对象更多是以业务目标或几层结构为基础的,重点又将转变成将HTML从Java代码中分离出来,同时仍坚持技术所提供的整体性和灵活性。在本书的第五章JSP部分,我们明白了整体和部分是如何只通过界定某个范围而爱制于不同环境。良好的应用设计就是建立在这个理念上并试着将目标对象,简报和对象操作分解成壁垒分明有区别的层次。使用JSP的另一个好处是,它让我们更清楚的区分网页制作角色或编程设计师与软件开发商。记住,JSP与Servlet的共同发展局面是它们将在Servlet本身的Java代码内嵌入HTML标记。在我们的讨论中,我们将Serlet纯粹当作是Java代码的集装箱,尽管在此同时,我们的整个HTML的显示平台是封装在一个JSP源网页里,那么接下来引发的问题是多少Java代码可以保留在我们的JSP源网页里,如果Java代码从JSP源网页中取出,将会在哪存放。让我们进一步对这个进行探讨研究。任何网上项目中,多角色和多责任是明显存在的。例如,一个程序员在网页制作时将充分发挥网页创作的角色(地位),同时即在Java编程语言中编写软件的过程中没有发挥出软件开发的作用。对于小型项目,这两个角色可能由同一个人或两个人密切配合完成,一个较大的项目将会由多个人完成,这些可能没有重叠技巧,而且如果过于依赖其它流程的话,创造性将会小一些。如果代码可以计算出一个包含Servlet而不是HTML标记,然后在软件开发角色个人的潜力存在和在网页制作角色中变得更加依赖于必要的工作进展和其它的,类似这种依赖可能造成更多的错误倾向环境,而这种事情被其它认员无意识的改变的环境变得更加普遍。这使我们更好观察到我们为什么继续开发基本Servlet的原因:它们是适当的便于普遍的己经计算出JSP页面的Java代码的集装箱,提供了把尽可能松散连接我们的JSP页面作为我们软件开发小组这一领域的焦点。当然,这将需要一个同样由个人来完成JSP来源页面,但是这种依赖减少,而这些页面变成制作团队的焦点。当然,如果同一个人完成两种角色工作,作为一个典型小型项目,类似这种依赖就不是最主要的关注。所以,我们应该尽量把包含我们的JSP页面的Java代码降为最低,为了维持这种发展角色间的清楚分离。正如我们曾讨论,许多这种Java代码是一个调处Servlet的合适适当的因素。代码是一种很常见的多样要求,例如认证,是为了一个调处Servlet的最佳选择。类似代码包含在一个地方,这些Servlet而不是潜在被切掉和粘贴成多样化的JSPs.我们还将要消除我们很多从JSP页面来的商业逻辑和数据访问代码和概括的内页JavaBeans,所谓工人或Beans帮手,我们开始看到一种从我们JSP代码活动中出来的模式的两个方面,一个是Servlet(或JSP技术),因为JSP主要在前面,而JavaBeans总是在后面的。我们称这种常见的模式为“前沿因子—因子后端”。类似的数字如下:“前沿因子—因子后端”:从另一种方式考虑我们所要要限制和封装的代码,也说是我们的JSP网页应该尽可能少地显示出Java代码的实施细节。相反,多数网页都应该传送我们的意图,即显示我们传统技术具有代表性的信息,指导他的从模型中获得状态指示或调去完成一些业务处理。12.4转移和发送在JSP和Servlet方面,转移与发送通常要求同时进行,即使这两个机制达到同一目标(即客户需求服务器上的资源和一个所服务于它的不同资源),但了解这两个机制的微妙差别是很重要的:当一个Servlet或JSP资源重新选择客户时(使用respone.sendRedirect程序ur1),自从内部操作是一个Http接续后,它的要求对象没有直接到喧第二资源。服务器传送一个Http302信息回客户,并告诉它这个资源己经转移到另一个URL上了,客户应该进入里内。最后也就是最初要求对象所需物体的生命线己进入第一个JSP,并以服务方式的结束或来自服务器的回应而终止。在一个发送机制里,要求所需对象被发送到第二资源,从而保持任何物体反应的要求以及它的指示上,没有来回的网络客户。这就允许第一个JSP做内部动转,然后发送信息到第二个JSP。(Servlets使用一个会连接机制物体),可以回头看看本书第五章的JSP时段,从本书中可以看到更清晰的图形。在分离动静容量的过程中,JSPs和Servlets能使用发送机制在他们之间执行任务。现在,让我们探讨如何建立这些系统。12.5结构在讨论具体的结构之前,我们可以利用所建造Servlets和JSPs的系统,值得提的是使用JSP技术的两个基本方法,在这一章里被讨论到的每个结构将建立在诸多方法之一的基础上:第一种方法是这里所指的网页中心(或客户服务器)的方式,且这种方式涉及到直接作用于JSP网页的指令缓助。第二种方法,发送员(或几层)方法,一个基本的Servlet或JSP充当调解员或操作员,发送指令给JSP网页和JavaBeans网页。我们将给出一个简单的例子来检测这些方法,这将展开来满足不同情况的要求。初步设想涉及到向网页界面提供不久将要出现的数字估计统计,它的臆测被保留着,并可以由另方法证实,看看谁猜测得最接近。当所要求情况变得更加复杂时,例如加入了持久机制的这一想法,那么解决方案也效变得更加复杂,我们用简洁而有准备的方式来展开讨论,以此来帮助我们建立满足这些要求的系统。12.6网页探讨中心使用客户服务器方式的值用结构己得到运用,他们包含一个或多个在客户机制上动行的应用程序,并连接到服务器运用的运转(PowerBuilder或OracleForms-based系统就是最好的例子)。CGIs和pre-servlt应用一般是建立在适全的简单的2层模式上,并随着Servlets的引入,2层应用也能在Java上产生。这种模式使JSPs或Servlets直接获取一些资源,如数据库遗留应用或用以服务客户的要求。早期的JSP规格称这种模式为“型号1”的编程方法。JSP页拦截并处理即将到来的请求服务,并把听应反馈给客户。不同于Servlet的这一情景,JSPs只是提供纯代码和从内容中分离代码放置在数据存取beans中,这一方体现在以下图表中。型号1的编程方法:这种方法的优点是,

温馨提示

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

评论

0/150

提交评论