Servlet和JSP技术简述(英文翻译)_第1页
Servlet和JSP技术简述(英文翻译)_第2页
Servlet和JSP技术简述(英文翻译)_第3页
Servlet和JSP技术简述(英文翻译)_第4页
Servlet和JSP技术简述(英文翻译)_第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

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

文档简介

AnOverviewofServletandJSPTechnologyGildasAvoineandPhilippeOechslinEPFL,Lausanne,SwitzerlandHISTORYOFJSPTheJavaServerPages(JSP)isakindofaccordingtowebofthescriptplaitdistancetechnique,similarcarriesthescriptlanguageofJavaintheserveroftheNetscapecompanyofserver-sideJavaScript(SSJS)andtheActiveServerPages(ASP)oftheMicrosoft.JSPcomparestheSSJSandASPtohavebettercanexpandsex,anditisnomoreexclusivethananyfactoryorsomeoneparticularserverofWeb.ThoughthenormofJSPistobedrawupbytheSuncompanyof,anyfactorycancarryouttheJSPonownsystem.TheAfterSunreleasetheJSP(theJavaServerPages)formally,thethiskindofnewWebapplicationdevelopmenttechniqueveryquicklycausedthepeople'sconcern.JSPprovidedaspecialdevelopmentenvironmentfortheWebapplicationthatestablishesthehighdynamicstate.AccordingtotheSunparlance,theJSPcanadapttoincludetheApacheWebServer,IIS4.0onthemarketatinsideof85%serverproduct.ThischapterwillintroducetherelatedknowledgeofJSPandDatabases,andJavaBeanrelatedcontents,isallcertainlyrougherintroductionamongthembasiccontents,sayperhapstoisaGuideonly,ifthereaderneedsthemoredetailedinformation,pleasingthebookofconsultthehomologousJSP.1.1.1GENERALIZETheJSP(JavaServerPages)isfromthecompanyofSunMicrosystemsinitiate,themanycompaniestheparticipatetothebuildupthetogetheroftheakindtheofdynamicthestatewebthepagetechniquestandard,theithavetheitintheconstructiontheofthedynamicstatethewebpagethestrongbutthedonottheespeciallyofthefunction.JSPandthetechniqueofASPoftheMicrosoftisveryalike.BothallprovidetheabilitythatmixeswithacertainprocedurecodeandisexplainbythelanguageenginetocarryouttheprocedurecodeinthecodeofHTML.Underneathwearesimpleofcarryontheintroductiontoit.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.1.1.2SOURCEOFJSPThetechniqueofJSPofthecompanyofSun,makingthepageofWebdevelopthepersonnelcanusetheHTMLperhapsmarkingofXMLtodesigntoturntheendpagewithformat.UsetheperhapssmallscriptfuturelifeofmarkingofJSPbecomesthedynamicstateonthepagecontents.(thecontentschangesaccordingtotheclaimof)TheJavaServletisatechnicalfoundationofJSP,andthelargeWebappliesthedevelopmentoftheproceduretoneedtheJavaServlettomatchwithwiththeJSPandthencancomplete,thisnameofServletcomesfromtheApplet,thelocaltranslationmethodofnowisalotof,thisbookinordernottomisconstruction,decidethedirectadoptionServletbutdon'tdoanytranslation,ifreaderwouldliketo,cancallitas"smallserviceprocedure".TheServletissimilartotraditionalCGI,ISAPI,NSAPIetc.Webproceduredevelopmentthefunctionofthetoolinfact,atusetheJavaServlethereafter,thecustomerneednotuseagainthelowlymethodofCGIofefficiency,alsoneednotuseonlytheabilitycometobornpageofWebofdynamicstateinthemethodofAPIthatacertainfixedWebserverterracecirculate.ManyserversofWeballsupporttheServlet,evennotsupporttheServletserverofWebdirectlyandcanalsopasstheadditionalappliedserverandthemoldpiecestosupporttheServlet.ReceivebenefitinthecharacteristicoftheJavacross-platform,theServletisalsoaterraceirrelevant,actually,aslongasmatchthenormofJavaServlet,theServletiscompletetohavenothingtodowithterraceandistohavenothingtodowithserverofWeb.BecausetheJavaServletisinternaltoprovidetheservicebythelinedistance,neednotstartaprogresstotheeachclaimses,andmakeuseofthemulti-threadingmechanismcanatthesametimeforseveralclaimservice,thereforetheefficiencyofJavaServletisveryhigh.ButtheJavaServletalsoisnottohasnoweakness,similartotraditionalCGI,ISAPI,theNSAPImethod,theJavaServletistomakeuseoftooutputtheHTMLlanguagesentencetocarryoutthedynamicstatewebpageof,ifdevelopthewholewebsitewiththeJavaServlet,theintegrationprocessofthedynamicstatepartandthestaticstatepageisanevil-forebodingdreamsimply.ForsolvingthiskindofweaknessoftheJavaServlet,theSUNreleasedtheJSP.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.TheJSPisanestablishmentatthemodelofJavaservletsonoftheexpressionlayertechnique,itmakestheplaitwritetheHTMLtobecomemoresimple.BeliketheSSJS,italsoallowsyoucarrythestaticstateHTMLcontentsandserversthescriptmixtoputtogethertheborndynamicstateexportation.JSPthescriptlanguagethattheJavaisthetacitapproval,however,beliketheASPandcanuseotherlanguages(suchasJavaScriptandVBScript),thenormofJSPalsoallowstouseotherlanguages.1.1.3JSPCHARACTERISTICSIsaserviceaccordingtothescriptlanguageinsomeonelanguageofthestaturessystemthiskindofdiscuss,theJSPshouldbeseemakeisakindofscriptlanguage.However,beakindofscriptlanguage,theJSPseemedtobetoostrongagain,almostcanuseallJavasintheJSP.Beakindofaccordingtotextoriginallyof,takemanifestationasthecentraldevelopmenttechnique,theJSPprovidedalladvantagesoftheJavaServlet,and,whencombinewithaJavaBeanstogether,providingakindofmakecontentsandmanifestationthatsimplewaythatlogicseparate.Separatethecontentsandadvantageoflogicalmanifestationsis,thepersonnelwhorenewsthepageexternalappearanceneednotknowthecodeofJava,andrenewtheJavaBeanspersonnelalsoneednotbedesignthewebpageofexpertinhand,canusetotakethepageofJavaBeansJSPtodefinethetemplateofWeb,tobuildupafromhavethealikeexternalappearanceofthewebsitethatpageconstitute.JavaBeanscompletesthedatatoprovide,havingnocodeofJavainthetemplatethus,thismeansthatthesetemplatescanbewrittenthepersonnelbyaHTMLplaittosupport.Certainly,canalsomakeuseoftheJavaServlettocontrolthelogicofthewebsite,adjustthroughtheJavaServlettousethewayofthedocumentofJSPtoseparatewebsiteoflogicandcontents.Generallyspeaking,inactualengineofJSP,thepageofJSPistheeditandtranslatetypewhilecarryout,notexplainthetypeof.Explainthedynamicstatewebpagedevelopmenttoolofthetype,suchasASP,PHP3etc.,becausespeedetc.reason,havealreadycan'tsatisfycurrentthelargeelectroniccommerceneedsappliedly,traditionaldevelopmenttechniquesareallattoeditandtranslatetheexecutivewaychange,suchastheASP→ASP+;PHP3→PHP4.IntheJSPnormbook,didnotrequesttheprocedureintheJSPcodepart(becalledtheScriptlet)andmustwritewiththeJavadefinitely.Actually,havesomeenginesofJSPareadoptiveotherscriptlanguagessuchastheEMAC-Script,etc.,butactuallythisafewscriptlanguagesalsoaretosetupontheJava,editandtranslatefortheServlettocarryoutof.WriteaccordingtothenormofJSP,havenoScriptletofrelationwithJavaalsoiscanof,however,mainlylieintheabilityandJavaBeans,theEnterpriseJavaBeansesbecauseoftheJSPstrongfunctiontoworktogether,soevenistheScriptletpartnottousetheJava,editandtranslateofperformancecodealsoshouldisrelatedwithJava.1.1.4JSPMECHANISMTocomprehendtheJSPhowunitethetechnicaladvantagethatabovevariousspeakof,cometocarryoutvariousresulteasily,thecustomermustunderstandthedifferentiationof"themoduledevelopsforthewebpageofthecenter"and"thepagedevelopsforthewebpageofthecenter"first.TheSSJSandASPareallinseveralyearagotorelease,thenetworkofthattimeisstillveryyoung,nooneknowstostillhaveinadditiontomakingallbusiness,datasandtheexpressionlogicentertheoriginalwebpageentirelyheapwhatbettersolvethemethod.Thiskindofmodelthattakepageasthecenterstudiesandgetstheveryfastdevelopmenteasily.However,alongwithchangeoftime,thepeopleknowthatthiskindofmethodisunwellinsetuplarge,theWebthatcanupgradeappliestheprocedure.Theexpressionlogicwriteinthescriptenvironmentwaslockinthepage,onlypassingtosheartosliceandgluetostickthencandriveheavyuse.Expressthelogictousuallymixtogetherwithbusinessandthedatalogics,whenthismakesbetheproceduremembertotrytochangeanexternalappearancethatappliestheprocedurebutdonotwanttobreakwithitslliedbusinesslogic,applytheprocedureofmaintenancebeliketowalkthesimilardifficultyontheeggshell.Infactinthebusinessenterprise,heavyusetheapplicationofthemodulealreadythroughverymature,noonewouldliketorewritethoselogicsfortheirappliedprocedure.HTMLandsketchthedesignerhandedovertotheimplementworkoftheirdesigntheWebplaittheonewhowrite,maketheyhavetodoublework-Usuallyisthehandicraftplaittowrite,becausehavenofittoolandcancarrythescriptandtheHTMLcontentsknottotheservertoputtogether.Chienbutspeech,applythecomplexityoftheprocedurealongwiththeWebtopromotecontinuously,thedevelopmentmethodthattakepageasthecenterlimitssextobecometogetupobviously.Atthesametime,thepeoplealwaysatlookforthebettermethodofbuilduptheWebapplicationprocedure,themodulespreadsincustomer'smachine/servertherealm.JavaBeansandActiveXwerepublishedthecompanytoexpandtoapplytheproceduredeveloperforJavaandWindowstousetocometodevelopthecomplicatedprocedurequicklyby"thefastapplicationproceduredevelopment"(RAD)tool.Thesetechniquesmaketheexpertinthesomerealmbeabletowritethemodulefortheperpendicularapplicationplaitintheskillarea,butthedevelopercangofetchtheusagedirectlybutneednotcontroltheexpertiseofthisrealm.Beakindoftakemoduleasthecentraldevelopmentterrace,theJSPappeared.ItwiththeJavaBeansandEnterpriseJavaBeans(EJB)moduleincludesthemodelofthebusinessandthedatalogicforfoundation,provideagreatdealoflabelandascriptterracestousetocometoshowintheHTMLpagefromthecontentsofJavaBeanscreationorsendapresentinreturn.BecauseofthepropertythatregardsthemoduleasthecenteroftheJSP,itcandriveJavaandnotthedeveloperofJavausesequally.NotthedeveloperofJavacanpasstheJSPlabel(Tags)tousetheJavaBeansthatthedeluxedeveloperofJavaestablish.ThedeveloperofJavanotonlycanestablishandusetheJavaBeans,butalsocanusethelanguageofJavatocometocontrolmoreaccuratelyintheJSPpageaccordingtotheexpressionlogicofthefirstfloorJavaBeans.SeenowhowJSPishandleclaimof.Inbasicclaimmodel,aclaimdirectlywassendtoJSPpagein.ThecodeofJSPcontrolstocarryonhourofthelogicprocessingandmoduleofJavaBeanses'handoverwitheachother,andthemanifestationresultindynamicstatebornly,mixingwiththeHTMLpageofthestaticstateHTMLcode.TheBeanscanbeJavaBeansormoduleofEJBs.Moreover,themorecomplicatedclaimmodelcanseemakefromisrequestotherJSPpagesofthepagecallsignorJavaServlets.TheengineofJSPwantstochasethecodeofJavathatthelabelofJSP,codeofJavaintheJSPpageevenallconvertsintothebigpiecetogetherwiththestaticstateHTMLcontentsactually.ThesecodespiecewasorganizedtheJavaServletthatcustomercannotseetogotobytheengineofJSP,thentheServleteditsandtranslatethemautomaticallybytecodeofJava.Thus,thevisitantthatisthewebsiterequestsaJSPpage,undertheconditionofitisnotknowing,analreadyborn,theServletactualfullgeneralthatpreparedtoeditandtranslatecompletesallworks,veryconcealmentbutagainandefficiently.TheServletistoeditandtranslateof,sothecodeofJSPinthewebpagedoesnotneedwhentheeverytimerequeststhatpageisexplain.TheengineofJSPneedtobeeditandtranslateafterServletthecodeendismodifyonlyonce,thenthisServletthatedittedandtranslatecanbecarryout.TheinviewofthefactJSPengineautoisborntoeditandtranslatetheServletalso,neednotprocedurememberbeginstoeditandtranslatethecode,sotheJSPcanbringvividsexthatfunctionandfastdevelopmentsneedthatyouareefficiently.ComparedwiththetraditionalCGI,theJSPhastheequaladvantage.First,onthespeed,thetraditionalprocedureofCGIneedstousethestandardimportationofthesystemtooutputtheequipmentstocarryoutthedynamicstatewebpageborn,buttheJSPisdirectismutuallytheconnectionwithserver.AndsayfortheCGI,eachinterviewneedstoaddtoaddaprogresstohandle,theprogressbuildupanddestroybyburningconstantlyandwillbeanotsmallburdenforcalculatorofbetheserverofWeb.Thenextinorder,theJSPisspecializedtodevelopbutdesignfortheWebof,itspurposeisforbuildingupaccordingtotheWebappliedprocedure,includedthenormandthetoolofathewholeset.UsethetechniqueofJSPcancombinealotofJSPpagestobecomeaWebapplicationprocedureveryexpediently.1.2AServlet'sJobServletsareJavaprogramsthatrunonWeborapplicationservers,actingasamiddlelayerbetweenrequestscomingfromWebbrowsersorotherclientsanddatabasesorapplicationsontheserver.Theirjobistoperformthefollowingtasks,asillustratedinFigure1-1.Figure1-11.Readtheexplicitdatasentbytheclient.TheendusernormallyentersthisdatainanHTMLformonaWebpage.However,thedatacouldalsocomefromanappletoracustomclientprogram.2.Readtheimplicitrequestdatasentbythebrowser.Figure1-1showsasinglearrowgoingfromtheclienttotheWebserver(thelayerwhereservletsandJSPexecute),buttherearereallytwovarietiesofdata:theexplicitdatathattheenduserentersinaformandthebehind-the-scenesinformation.Bothvarietiesarecritical.Theinformationincludescookies,informationaboutmediatypesandcompressionschemesthebrowserunderstands,andsoon.3.Generatetheresults.Thisprocessmayrequiretalkingtoadatabase,executinganRMIorEJBcall,invokingaWebservice,orcomputingtheresponsedirectly.Yourrealdatamaybeinarelationaldatabase.Fine.Butyourdatabaseprobablydoesn'tspeakorreturnresultsinHTML,sotheWebbrowsercan'ttalkdirectlytothedatabase.Evenifitcould,forsecurityreasons,youprobablywouldnotwantitto.Thesameargumentappliestomostotherapplications.YouneedtheWebmiddlelayertoextracttheincomingdatafromthestream,talktotheapplication,andembedtheresultsinsideadocument.4.Sendtheexplicitdata(i.e.,thedocument)totheclient.Thisdocumentcanbesentinavarietyofformats,includingtext(HTMLorXML),binary(GIFimages),orevenacompressedformatlikegzipthatislayeredontopofsomeotherunderlyingformat.But,HTMLisbyfarthemostcommonformat,soanimportantservlet/JSPtaskistowraptheresultsinsideofHTML.5.Sendtheimplicitresponsedata.Figure1-1showsasinglearrowgoingfromtheWebmiddlelayer(theservletorJSPpage)totheclient.But,therearereallytwovarietiesofdatasent:thedocumentitselfandthebehind-the-scenesinformation.Again,bothvarietiesarecriticaltoeffectivedevelopment.Sendingresponsedatainvolvestellingthebrowserorotherclientwhattypeofdocumentisbeingreturned(e.g.,HTML),settingcookiesandcachingparameters,andothersuchtasks.1.3WhyBuildWebPagesDynamically?manyclientrequestscanbesatisfiedbyprebuiltdocuments,andtheserverwouldhandletheserequestswithoutinvokingservlets.Inmanycases,however,astaticresultisnotsufficient,andapageneedstobegeneratedforeachrequest.ThereareanumberofreasonswhyWebpagesneedtobebuilton-the-fly:1.TheWebpageisbasedondatasentbytheclient.Forinstance,theresultspagefromsearchenginesandorder-confirmationpagesatonlinestoresarespecifictoparticularuserrequests.Youdon'tknowwhattodisplayuntilyoureadthedatathattheusersubmits.Justrememberthattheusersubmitstwokindsofdata:explicit(i.e.,HTMLformdata)andimplicit(i.e.,requestheaders).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,servletsarenotrestrictedtoWeborapplicationserversthathandlerequestsbutcanbeusedforothertypesofserversaswell.Forexample,servletscouldbeembeddedinFTPormailserverstoextendtheirfunctionality.And,aservletAPIforSIP(SessionInitiationProtocol)serverswasrecentlystandardized(see:///en/jsr/detail?id=116).Inpractice,however,thisuseofservletshasnotcaughton,andwe'llonlybediscussingservlets.1.4TheAdvantagesofServletsOver"Traditional"CGIJavaservletsaremoreefficient,easiertouse,morepowerful,moreportable,safer,andcheaperthantraditionalCGIandmanyalternativeCGI-liketechnologies.1.EfficientWithtraditionalCGI,anewprocessisstartedforeachrequest.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,readingandsettingheaders,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://java.sun/j2ee/),soindustrysupportforservletsisbecomingevenmorepervasive.5.InexpensiveAnumberoffreeorveryinexpensiveWebserversaregoodfordevelopmentuseordeploymentoflow-ormedium-volumeWebsites.Thus,withservletsandJSPyoucanstartwithafreeorinexpensiveserverandmigratetomoreexpensiveserverswithhigh-performancecapabilitiesoradvancedadministrationutilitiesonlyafteryourprojectmeetsinitialsuccess.ThisisincontrasttomanyoftheotherCGIalternatives,whichrequireasignificantinitialinvestmentforthepurchaseofaproprietarypackage.Priceandportabilityaresomewhatconnected.Forexample,Martytriestokeeptrackofthecountriesofreadersthatsendhimquestionsbyemail.Indiawasnearthetopofthelist,probably#2behindtheU.S.MartyalsotaughtoneofhisJSPandservlettrainingcourses(see://courses.coreservlets/)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.Ifthe

温馨提示

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

评论

0/150

提交评论