JSP技术概述外文翻译.docx

上传人:b****7 文档编号:10251705 上传时间:2023-02-09 格式:DOCX 页数:9 大小:25.92KB
下载 相关 举报
JSP技术概述外文翻译.docx_第1页
第1页 / 共9页
JSP技术概述外文翻译.docx_第2页
第2页 / 共9页
JSP技术概述外文翻译.docx_第3页
第3页 / 共9页
JSP技术概述外文翻译.docx_第4页
第4页 / 共9页
JSP技术概述外文翻译.docx_第5页
第5页 / 共9页
点击查看更多>>
下载资源
资源描述

JSP技术概述外文翻译.docx

《JSP技术概述外文翻译.docx》由会员分享,可在线阅读,更多相关《JSP技术概述外文翻译.docx(9页珍藏版)》请在冰豆网上搜索。

JSP技术概述外文翻译.docx

JSP技术概述外文翻译

外文原文

OverviewofJSPTechnology

BenefitsofJSP

JSPpagesaretranslatedintoservlets.So,fundamentally,anytaskJSPpagescanperformcouldalsobeaccomplishedbyservlets.However,thisunderlyingequivalencedoesnotmeanthatservletsandJSPpagesareequallyappropriateinallscenarios.Theissueisnotthepowerofthetechnology,itistheconvenience,productivity,andmaintainabilityofoneortheother.Afterall,anythingyoucandoonaparticularcomputerplatformintheJavaprogramminglanguageyoucouldalsodoinassemblylanguage.Butitstillmatterswhichyouchoose.

JSPprovidesthefollowingbenefitsoverservletsalone:

•ItiseasiertowriteandmaintaintheHTML.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.

AdvantagesofJSPOverCompetingTechnologies

Anumberofyearsago,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.EvenASP(aproductfromtheverysoftwarecompanyoftheaforementionedmanager)popularizedthisapproachbeforeJSPcamealonganddecidedtojumponthebandwagon.Infact,JSPnotonlyadoptedthegeneralidea,itevenusedmanyofthesamespecialtagsasASPdid.

So,thequestionbecomes:

whyuseJSPinsteadofoneoftheseothertechnologies?

Ourfirstresponseisthatwearenotarguingthateveryoneshould.Severalofthoseothertechnologiesarequitegoodandarereasonableoptionsinsomesituations.Inothersituations,however,JSPisclearlybetter.Hereareafewofthereasons.

Versus.NETandActiveServerPages(ASP)

.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.

VersusPHP

PHP(arecursiveacronymfor"PHP:

HypertextPreprocessor")isafree,open-source,HTML-embeddedscriptinglanguagethatissomewhatsimilartobothASPandJSP.OneadvantageofJSPisthatthedynamicpartiswritteninJava,whichalreadyhasanextensiveAPIfornetworking,databaseaccess,distributedobjects,andthelike,whereasPHPrequireslearninganentirelynew,lesswidelyusedlanguage.AsecondadvantageisthatJSPismuchmorewidelysupportedbytoolandservervendorsthanisPHP.

VersusPureServlets

JSPdoesn'tprovideanycapabilitiesthatcouldn't,inprinciple,beaccomplishedwithservlets.Infact,JSPdocumentsareautomaticallytranslatedintoservletsbehindthescenes.Butitismoreconvenienttowrite(andtomodify!

)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,andperformingtasks(suchasredirection)thatinvolvelittleornooutput.

4.SometasksarebetteraccomplishedbyacombinationofservletsandJSPthanbyeitherservletsorJSPalone.

VersusJavaScript

JavaScript,whichiscompletelydistinctfromtheJavaprogramminglanguage,isnormallyusedtodynamicallygenerateHTMLontheclient,buildingpartsoftheWebpageasthebrowserloadsthedocument.ThisisausefulcapabilityanddoesnotnormallyoverlapwiththecapabilitiesofJSP(whichrunsonlyontheserver).JSPpagesstillincludeSCRIPTtagsforJavaScript,justasnormalHTMLpagesdo.Infact,JSPcanevenbeusedtodynamicallygeneratetheJavaScriptthatwillbesenttotheclient.So,JavaScriptisnotacompetingtechnology;itisacomplementaryone.

ItisalsopossibletouseJavaScriptontheserver,mostnotablyonSunONE(formerlyiPlanet),IIS,andBroadVisionservers.However,Javaismorepowerful,flexible,reliable,andportable.

VersusWebMacroorVelocity

JSPisbynomeansperfect.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(.warfiles)fordeployingWebapplications.AllJSP-compatibleserversmustsupportthesestandards.FilterscanbesetuptoapplytoanynumberofservletsorJSPpages,butnottononstandardresources.ThesamegoesforWebapplicationsecuritysettings.

Besides,thetremendousindustrysupportforJSPandservlettechnologyresultsinimprovementsthatmitigatemanyofthecriticismsofJSP.Forexample,theJSPStandardTagLibraryandtheJSP2.0expressionlanguageaddresstwoofthemostwell-foundedcriticisms:

thelackofgooditerationconstructsandthedifficultyofaccessingdynamicresultswithoutusingeitherexplicitJavacodeorverbosejsp:

useBeanelements.

10.4MisconceptionsAboutJSP

ForgettingJSPIsServer-Side

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 其它课程

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1