




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
计算机外文英文翻译JSP技术概述外文原文OverviewofJSPTechnologyBenefitsofJSPJSPpagesaretranslatedintoservlets.So,fundamentally,anytaskJSPpagescanperformcouldalsobeaccomplishedbyservlets.However,thisunderlyingequivalencedoesnotmeanthatservletsandJSPpagesareequallyappropriateinallscenarios.Theissueisnotthepowerofthetechnology,itistheconvenience,productivity,andmaintainabilityofoneortheother.Afterall,anythingyoucandoonaparticularcomputerplatformintheJavaprogramminglanguageyoucouldalsodoinassemblylanguage.Butitstillmatterswhichyouchoose.JSPprovidesthefollowingbenefitsoverservletsalone:?Itiseasiertowriteandmaintainthe6>HTML.YourstaticcodeisordinaryHTML:noextrabackslashes,nodoublequotes,andnolurkingJavasyntax.?YoucanusestandardWeb-sitedevelopmenttools.EvenHTMLtoolsthatknownothingaboutJSPcanbeusedbecausetheysimplyignoretheJSPtags.?Youcandivideupyourdevelopmentteam.TheJavaprogrammerscanworkonthedynamiccode.TheWebdeveloperscanconcentrateonthepresentationlayer.Onlargeprojects,thisdivisionisveryimportant.Dependingonthesizeofyourteamandthecomplexityofyourproject,youcanenforceaweakerorstrongerseparationbetweenthestaticHTMLandthedynamiccontent.Now,thisdiscussionisnottosaythatyoushouldstopusingservletsanduseonlyJSPinstead.Bynomeans.Almostallprojectswilluseboth.Forsomerequestsinyourproject,youwilluseservlets.Forothers,youwilluseJSP.Forstillothers,youwillcombinethemwiththeMVCarchitecture.Youwanttheappropriatetoolforthejob,andservlets,bythemselves,donotcompleteyourtoolkit.AdvantagesofJSPOverCompetingTechnologiesAnumberofyearsago,Martywasinvitedtoattendasmall20-personindustryroundtablediscussiononsoftwaretechnology.SittingintheseatnexttoMartywasJamesGosling,inventoroftheJavaprogramminglanguage.Sittingseveralseatsawaywasahigh-levelmanagerfromaverylargesoftwarecompanyinRedmond,Washington.Duringthediscussion,themoderatorbroughtupthesubjectofJini,whichatthattimewasanewJavatechnology.Themoderatoraskedthemanagerwhathethoughtofit,andthemanagerrespondedthatitwastooearlytotell,butthatitseemedtobeanexcellentidea.Hewentontosaythattheywouldkeepaneyeonit,andifitseemedtobecatchingon,theywouldfollowhiscompany'susual"embraceandextend"strategy.Atthispoint,Goslinglightheartedlyinterjected"Youmeandisgraceanddistend."Now,thegrievancethatGoslingwasairingwasthathefeltthatthiscompanywouldtaketechnologyfromothercompaniesandsubornitfortheirownpurposes.Butguesswhat?Theshoeisontheotherfoothere.TheJavacommunitydidnotinventtheideaofdesigningpagesasamixtureofstaticHTMLanddynamiccodemarkedwithspecialtags.Forexample,ColdFusiondidityearsearlier.EvenASPaproductfromtheverysoftwarecompanyoftheaforementionedmanagerpopularizedthisapproachbeforeJSPcamealonganddecidedtojumponthebandwagon.Infact,JSPnotonlyadoptedthegeneralidea,itevenusedmanyofthesamespecialtagsasASPdid.So,thequestionbecomes:whyuseJSPinsteadofoneoftheseothertechnologies?Ourfirstresponseisthatwearenotarguingthateveryoneshould.Severalofthoseothertechnologiesarequitegoodandarereasonableoptionsinsomesituations.Inothersituations,however,JSPisclearlybetter.Hereareafewofthereasons.Versus.NETandActiveServerPagesASP.NETiswell-designedtechnologyfromMicrosoft.ASP.NETisthepartthatdirectlycompeteswithservletsandJSP.TheadvantagesofJSParetwofold.First,JSPisportabletomultipleoperatingsystemsandWebservers;youaren'tlockedintodeployingonWindowsandIIS.Althoughthecore.NETplatformrunsonafewnon-Windowsplatforms,theASPpartdoesnot.YoucannotexpecttodeployseriousASP.NETapplicationsonmultipleserversandoperatingsystems.Forsomeapplications,thisdifferencedoesnotmatter.Forothers,itmattersgreatly.Second,forsomeapplicationsthechoiceoftheunderlyinglanguagemattersgreatly.Forexample,although.NET'sC#languageisverywelldesignedandissimilartoJava,fewerprogrammersarefamiliarwitheitherthecoreC#syntaxorthemanyauxiliarylibraries.Inaddition,manydevelopersstillusetheoriginalversionofASP.Withthisversion,JSPhasaclearadvantageforthedynamiccode.WithJSP,thedynamicpartiswritteninJava,notVBScriptoranotherASP-specificlanguage,soJSPismorepowerfulandbettersuitedtocomplexapplicationsthatrequirereusablecomponents.YoucouldmakethesameargumentwhencomparingJSPtothepreviousversionofColdFusion;withJSPyoucanuseJavaforthe"realcode"andarenottiedtoaparticularserverproduct.However,thecurrentreleaseofColdFusioniswithinthecontextofaJ2EEserver,allowingdeveloperstoeasilymixColdFusionandservlet/JSPcode.VersusPHPPHParecursiveacronymfor"PHP:HypertextPreprocessor"isafree,open-source,HTML-embeddedscriptinglanguagethatissomewhatsimilartobothASPandJSP.OneadvantageofJSPisthatthedynamicpartiswritteninJava,whichalreadyhasanextensiveAPIfornetworking,databaseaccess,distributedobjects,andthelike,whereasPHPrequireslearninganentirelynew,lesswidelyusedlanguage.AsecondadvantageisthatJSPismuchmorewidelysupportedbytoolandservervendorsthanisPHP.VersusPureServletsJSPdoesn'tprovideanycapabilitiesthatcouldn't,inprinciple,beaccomplishedwithservlets.Infact,JSPdocumentsareautomaticallytranslatedintoservletsbehindthescenes.Butitismoreconvenienttowriteandtomodify!regularHTMLthantouseazillionprintlnstatementstogeneratetheHTML.Plus,byseparatingthepresentationfromthecontent,youcanputdifferentpeopleondifferenttasks:yourWebpagedesignexpertscanbuildtheHTMLbyusingfamiliartoolsandeitherleaveplacesforyourservletprogrammerstoinsertthedynamiccontentorinvokethedynamiccontentindirectlybymeansofXMLtags.DoesthismeanthatyoucanjustlearnJSPandforgetaboutservlets?Absolutelynot!JSPdevelopersneedtoknowservletsforfourreasons:1.JSPpagesgettranslatedintoservlets.Youcan'tunderstandhowJSPworkswithoutunderstandingservlets.2.JSPconsistsofstaticHTML,special-purposeJSPtags,andJavacode.WhatkindofJavacode?Servletcode!Youcan'twritethatcodeifyoudon'tunderstandservletprogramming.3.SometasksarebetteraccomplishedbyservletsthanbyJSP.JSPisgoodatgeneratingpagesthatconsistoflargesectionsoffairlywellstructuredHTMLorothercharacterdata.Servletsarebetterforgeneratingbinarydata,buildingpageswithhighlyvariablestructure,andperformingtaskssuchasredirectionthatinvolvelittleornooutput.4.SometasksarebetteraccomplishedbyacombinationofservletsandJSPthanbyeitherservletsorJSPalone.VersusJavaScriptJavaScript,whichiscompletelydistinctfromtheJavaprogramminglanguage,isnormallyusedtodynamicallygenerateHTMLontheclient,buildingpartsoftheWebpageasthebrowserloadsthedocument.ThisisausefulcapabilityanddoesnotnormallyoverlapwiththecapabilitiesofJSPwhichrunsonlyontheserver.JSPpagesstillincludeSCRIPTtagsforJavaScript,justasnormalHTMLpagesdo.Infact,JSPcanevenbeusedtodynamicallygeneratetheJavaScriptthatwillbesenttotheclient.So,JavaScriptisnotacompetingtechnology;itisacomplementaryone.ItisalsopossibletouseJavaScriptontheserver,mostnotablyonSunONEformerlyiPlanet,IIS,andBroadVisionservers.However,Javaismorepowerful,flexible,reliable,andportable.VersusWebMacroorVelocityJSPisbynomeansperfect.Manypeoplehavepointedoutfeaturesthatcouldbeimproved.Thisisagoodthing,andoneoftheadvantagesofJSPisthatthespecificationiscontrolledbyacommunitythatdrawsfrommanydifferentcompanies.So,thetechnologycanincorporateimprovementsinsuccessivereleases.However,somegroupshavedevelopedalternativeJava-basedtechnologiestotrytoaddressthesedeficiencies.This,inourjudgment,isamistake.Usingathird-partytoollikeApacheStrutsthataugmentsJSPandservlettechnologyisagoodideawhenthattooladdssufficientbenefittocompensatefortheadditionalcomplexity.ButusinganonstandardtoolthattriestoreplaceJSPisabadidea.Whenchoosingatechnology,youneedtoweighmanyfactors:standardization,portability,integration,industrysupport,andtechnicalfeatures.TheargumentsforJSPalternativeshavefocusedalmostexclusivelyonthetechnicalfeaturespart.Butportability,standardization,andintegrationarealsoveryimportant.Forexample,theservletandJSPspecificationsdefineastandarddirectorystructureforWebapplicationsandprovidestandardfiles.warfilesfordeployingWebapplications.AllJSP-compatibleserversmustsupportthesestandards.FilterscanbesetuptoapplytoanynumberofservletsorJSPpages,butnottononstandardresources.ThesamegoesforWebapplicationsecuritysettings.Besides,thetremendousindustrysupportforJSPandservlettechnologyresultsinimprovementsthatmitigatemanyofthecriticismsofJSP.Forexample,theJSPStandardTagLibraryandtheJSP2.0expressionlanguageaddresstwoofthemostwell-foundedcriticisms:thelackofgooditerationconstructsandthedifficultyofaccessingdynamicresultswithoutusingeitherexplicitJavacodeorverbosejsp:useBeanelements.10.4MisconceptionsAboutJSPForgettingJSPIsServer-SideTechnologyHerearesometypicalquestionsMartyhasreceivedmostofthemrepeatedly.?OurserverisrunningJDK1.4.So,howdoIputaSwingcomponentinaJSPpage??HowdoIputanimageintoaJSPpage?IdonotknowtheproperJavaI/Ocommandstoreadimagefiles.?SinceTomcatdoesnotsupportJavaScript,howdoImakeimagesthatarehighlightedwhentheusermovesthemouseoverthem??OurclientsuseolderbrowsersthatdonotunderstandJSP.Whatshouldwedo??Whenourclientsuse"ViewSource"inabrowser,howcanIpreventthemfromseeingtheJSPtags?Allofthesequestionsarebasedupontheassumptionthatbrowsersknowsomethingabouttheserver-sideprocess.Buttheydonot.Thus:?ForputtingappletswithSwingcomponentsintoWebpages,whatmattersisthebrowser'sJavaversion?theserver'sversionisirrelevant.IfthebrowsersupportstheJava2platform,youusethenormalAPPLETorJavaplug-intagandwoulddosoevenifyouwereusingnon-Javatechnologyontheserver.?YoudonotneedJavaI/Otoreadimagefiles;youjustputtheimageinthedirectoryforWebresourcesi.e.,twolevelsupfromWEB-INF/classesandoutputanormalIMGtag.?Youcreateimagesthatchangeunderthemousebyusingclient-sideJavaScript,referencedwiththeSCRIPTtag;thisdoesnotchangejustbecausetheserverisusingJSP.?Browsersdonot"support"JSPatall?theymerelyseetheoutputoftheJSPpage.So,makesureyourJSPoutputsHTMLcompatiblewiththebrowser,justasyouwoulddowithstaticHTMLpages.?And,ofcourseyouneednotdoanythingtopreventclientsfromseeingJSPtags;thosetagsareprocessedontheserverandarenotpartoftheoutputthatissenttotheclient.ConfusingTranslationTimewithRequestTimeAJSPpageisconvertedintoaservlet.Theservletiscompiled,loadedintotheserver'smemory,initialized,andexecuted.Butwhichstephappenswhen?Toanswerthatquestion,remembertwopoints:?TheJSPpageistranslatedintoaservletandcompiledonlythefirsttimeitisaccessedafterhavingbeenmodified.?Loadingintomemory,initialization,andexecutionfollowthenormalrulesforservlets.Table1givessomecommonscenariosandtellswhetherornoteachstepoccursinthatscenario.Themostfrequentlymisunderstoodentriesarehighlighted.Whenreferringtothetable,notethatservletsresultingfromJSPpagesusethe_jspServicemethodcalledforbothGETandPOSTrequests,notdoGetordoPost.Also,forinitialization,theyusethejspInitmethod,nottheinitmethod.Table1.JSPOperationsinVariousScenarios?JSPpagetranslatedintoservletServletcompiledServletloadedintoserver'smemoryjspInitcalled_jspServicecalledPagefirstwrittenRequest1YesYesYesYesYesRequest2NoNoNoNoYesServerrestartedRequest3NoNoYesYesYesRequest4NoNoNoNoYesPagemodifiedRequest5YesYesYesYesYesRequest6NoNoNoNoYes?中文翻译JSP技术概述一、JSP的好处JSP页面最终会转换成servler。因而,从根本上,JSP页面能够执行的任何任务都可以用servler来完成。然而,这种底层的等同性并不意味着servler和JSP页面对于所有的情况都等同适用。问题不在于技术的能力,而是二者在便利性、生产率和可维护性上的不同。毕竟,在特定平台上能够用Java编程语言完成的事情,同样可以用汇编语言来完成,但是选择哪种语言依旧十分重要。和单独使用servler相比,JSP提供下述好处:JSP中HTML的编写与维护更为简单。JSP中可以使用常规的HTML:没有额外的反斜杠,没有额外的双引号,也没有暗含的Java语法。能够使用标准的网站开发工具。即使对那些对JSP一无所知的HTML工具,我们也可以使用,因为它们会忽略JSP标签〔JSPtags〕。可以对开发团队进行划分。Java程序员可以致力于动态代码。Web开发人员可以将经理集中在表示层〔presentationlayer〕上。对于大型的工程,这种划分极为重要。依据开发团队的大小,及工程的复杂程度,可以对静态HTML和动态内容进行弱别离〔weakerseparation〕和强别离〔strongerseparation〕。在此,这个讨论并不是让您停止使用servlets,只使用JSP。几乎所有的工程都会同时用到这两种技术。针对工程中的某些请求,您可能会在MVC构架下组合使用这两项技术。我们总是希望用适当的工具完成相对应的工作,仅仅是servlet并不能填满您的工具箱。二、JSP相对于竞争技术的优势许多年前,Marty受到邀请,参加一个有关软件技术的小型20个人研讨会.做在Marty旁边的人是JamesGoslingJava编程语言的创造者。隔几个位置,是来自华盛顿一家大型软件公司的高级经理。在讨论过程中,研讨会的主席提出了Jini的议题,这在当时是一项新的Java技术.主席向该经理询问他的想法.他继续说,他们会持续关注这项技术,如果这项技术变得流行起来,他们会遵循公司的“接受并扩充embraceandextend〞的策略.此时,Gosling随意地插话说“你的意思其实就是不接受且不扩充disgraceanddistend。〞在此,Gosling的抱怨显示出,他感到这个公司会从其他公司那里拿走技术,用于他们自己的目的.但你猜这次怎么样?这次鞋子穿在了另一只脚上。Java社团没有创造这一思想将页面设计成由静态HTML和用特殊标签标记的动态代码混合组成.。ColdFusion多年前就已经这样做了。甚至ASP来自于前述经理所在公司的一项产品都在JSP出现之前推广了这种方式。实际上,JSP不只采用了这种通用概念,它甚至使用许多和ASP相同的特殊标签。因此,问题变成:为什么使用JSP,而不使用其他技术呢?我们的第一反响是我们不是在争论所有的人应该做什么。其他这些技术中,有一些也很不错,在某些情况下也确实是合情合理的选择.然而,在其他情形中,JSP明显要更好一些。下面给出几个理由。与.NET和ActiveServerPagesASP相比.NET是Microsoft精心设计的一项技术。ASP.NET是与servlets和JSP直接竞争的技术。JSP的优势表达在两个方面。首先,JSP可以移植到多种操作系统和Web效劳器,您不必仅仅局限于部署在Windows和IIS上尽管核心.NET平台可以在好几种非Windows平台上运行,但ASP这一局部不可以。您不能期望可以将重要的ASP.NET
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 徽县特岗面试真题及答案
- 黄石教资面试真题及答案
- 榆次二模试题及答案英语
- 家具行业的市场营销对产品设计的指导作用研究试题及答案
- 新能源汽车技术的质量保障体系试题及答案
- 砂轮机安全试题及答案
- 粗苯工艺培训试题及答案
- 家具行业的人才需求与培养问题试题及答案
- 民办教育机构2025年合规运营风险防范与品牌影响力提升分析
- 医药企业研发外包(CRO)模式在2025年的国际合作与本土化发展报告
- 《现代农业生物技术育种方法》课件
- 喝酒协议书范本
- 贵州文物调查研究-从文物看中华民族共同体历史的区域实践知到智慧树章节测试课后答案2024年秋贵州民族大学
- 2025届甘肃省定西市安定区中考生物对点突破模拟试卷含解析
- 电力公司深度调峰摸底试验方案
- 《竹节参茎叶中脂溶性成分的研究》
- 化工设备巡检培训
- 《汽车文化》2024年课程标准(含课程思政设计)
- 空气源热泵培训资料
- 化妆品合伙协议书
- DB64-266-2018:建筑工程资料管理规程-201-250
评论
0/150
提交评论