




已阅读5页,还剩17页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
0英文文献OverviewofJSPTechnologyandJSPapplicationframeworks1.BenefitsofJSPJSPpagesaretranslatedintoservlets.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,youcanenforceaweakerorstrongerseparationbetweenthestaticHTMLanddynamiccontentonaweakseparation(weakerseparation)andstrongseparation(strongerseparation).Inthiscase,thisdiscussiondoesnotallowyoutostopusingservlets,usingonlyJSP.Almostalloftheprojectswillbeusedbothtechnologiessimultaneously.Somerequestsfortheproject,youmaybeusedincombinationintheMVCframeworkofthesetwotechnologies.Wealwayswanttousethepropertoolstocompletethejobthatcorrespondsmerelyservletdoesnotfillyourtoolbox.2.JSPadvantagerelativetocompetingtechnologies1Manyyearsago,Martywasinvitedtoparticipateinasoftwaretechnologyrelatedtosmall(20people)seminartodonextinMartyJamesGosling-whoistheinventoroftheJavaprogramminglanguage.Everyfewpositions,aseniormanagerfromWashington,alargesoftwarecompany.Duringthediscussion,theChairmanoftheseminartopicspresentedJini,whichatthetimewasanewJavatechnology.Chairmanaskedhisthoughtstothemanagerandhewentontosaythattheywillcontinuetofocusthistechnology,Ifthistechnologybecomespopular,theywillfollowtheacceptandexpansion(embraceandextend)strategyofthecompanyatthistime,Goslingcasuallyinterjected,Youmeaninfactthatisnotacceptableanddoesnotexpand(disgraceanddistend).Here,Goslingcomplaintshowsthathefeltthatthecompanywilltakethetechnologyfromwhereothercompaniesfortheirownpurposes,buthowdoyouthinkthiskind?Theshoesontheotherfoot.Javacommunitydidnotinventthisidea-thepagedesignedbythestaticanddynamicHTMLcodelabelmarkedwithaspecialblendcomposition.ColdFusionyearsago,hasalreadydoneso.(Aproductfromthepreviousmanagerscompany)evenbeforetheJSPASPhaveappearedtopromotethisapproach.Infact,JSPnotonlyadoptedthisgeneralconcept,itevenusesthesamelotandASPspeciallabel.Sothequestionbecomes:WhyuseJSP,withouttheuseofothertechnologiesitourfirstreactionisthatwearenotarguingthatallpeopleshoulddo?.Theseothertechnologies,therearesomeverygood,indeedinsomecasesitisreasonablechoice,however,inothercases,JSPsignificantlybetter.Hereareafewreasons.2.1comparedwith.NETandActiveServerPages(ASP).NETisatechnologythatMicrosoftdesigned.ASP.NETisindirectcompetitionwithservletsandJSPtechnologies.TheadvantagesofJSPreflectedintwoaspects.First,JSPcanbeportedtomultipleoperatingsystemsandWebservers,youdonotjustlimitedtothedeploymenteventhoughthecore.NETplatformcanrunonseveralnon-WindowsplatformsonWindowsandIIS,butnotthispartofASP.YoucannotexpecttobeabletodeployanASP.NETapplicationtoavarietyofimportantserversandoperatingsystems.Forsomeapplications,thisdifferencehasnoeffect.However,someapplications,thisdifferenceisveryimportant.Secondly,theselectionofcertainapplications,theunderlyinglanguageis2essential.Forexample,although.NETC#languagewelldesigned,andthelike,andJava,butfewarefamiliarwiththecoreC#syntaxandnumeroustoolslibraryprogrammers.Inaddition,manydevelopersstillusetheoriginalversionofASP.Relativetothisversion,JSPhasaclearadvantageintermsofdynamiccode.UseJSP,dynamicpartiswritteninJava,ratherthanaproprietaryASPVBScriptlanguageovertheother,soJSPstronger,moresuitableforcomplexapplicationsrequiredcomponentreuse.WhentheJSPcomparisonwithpreviousversionsofColdFusion,youmaygetthesameconclusion.ApplicationJSP,youcanuseJavatowriterealcode,donotdependonaspecificserverproducts.However,thecurrentversionofColdFusionmeettheJ2EEserverenvironmentthatallowsdeveloperstoeasilymixColdFusionandServlet/JSPcode.ComparedwithPHP2.2PHP(PHP:HypertextPreprocessorisarecursiveacronym)isafree,opensource,HTMLembeddedscriptinglanguage,similartoASPandJSPhassomedegree.OneadvantageofthedynamicpartoftheJSPiswritteninJava,andJavaalreadyinnetworking,databaseaccessareas,suchasdistributedobjecthasanextensiveAPI,andPHPneedtolearnanewapplicationofarelativelywiderangeoflanguages.ThesecondadvantageisthatJSPandPHPcompared,JSPhasaverywiderangeofsupporttoolsandserverproviders.ComparedwithpureServlet2.3Inprinciple,JSPServletcannotprovidecompletefunctionality.Infact,JSPdocumentsareautomaticallyinthebackgroundConvertedintoaServlet.Butthewriting(andmodify)theconventionalHTML,HTMLgenerationthanmanyprintlnstatementismuchmoreconvenient.Inaddition,byseparatingthesaidcontent,youcanassigndifferentpeoplefordifferenttasks:WebdesignerstousefamiliartoolstobuildHTML,orleavespacefortheServletprogrammerstoinsertdynamiccontent,dynamiccontentorindirectlybycallingtheXMLtags.DoesthismeanthatyoucanjustlearnJSP,Servletwillbethrownintothesideofit?Ofcoursenot!Asthefollowingfourreasons,JSPdevelopersneedtounderstandServlet:(1)JSPpagesareconvertedintoServlet.UnderstandJSPServletcannotknowhowtowork.3(2)JSPfromstaticHTML,JSPtagsandJava-specificcode.WhattypeofJavacode?OfcourseServletcode!IfyoudonotunderstandtheServletprogramming,thenyoucannotwritethiscode.(3)tocompletesometasksbetterbyusingJSPServletcompletedratio.JSPpagesgeneratedbyalargenumberofgoodorganizedHTMLorotherstructureddataconsistingofcharacter.Servletspecializesgeneratebinarydata,buildstructuresanddiversepages,andtaskexecutionoutputwithlittleornooutput(suchasredirection).(4)SometasksaremoresuitableforcombinationwithServletandJSPtocomplete,ratherthanaloneServletorJSP.ComparedwithJavaScript2.4JavaScriptandJavaprogramminglanguageistotallydifferent,theformerisgenerallyusedtodynamicallygenerateHTMLontheclient,tobuildpartofthecontentofthepagewhenthebrowserloadsthedocument.Thisisausefulfeature,generallyoverlapwithJSPfunction(onlyrunsontheserverside)doesnotoccur.LikeconventionalHTMLpages,JSPpagescanstillincludeaSCRIPTtagforJavaScript.Infact,JSPcanbeusedtodynamicallygenerateevensenttotheclientJavaScript.Thus,JavaScriptisnotacompetingtechnology,whichisacomplementarytechnology.JavaScriptcanalsobeusedontheserverside,themostattentionbecausepeopleareSUNONE(formerlytheiPlanet),IIS,andBroadVisionserver.However,Javaismorepowerful,flexible,reliableandportable.ComparedwithWebMacroandVelocity2.5JSPbynomeansperfect.ManypeoplehavepointedouttheJSPcanbeimprovedfeatures.Thisisagoodthing,oneoftheadvantagesisthattheJSPspecificationbymanydifferentcompaniescontrolledsocieties.Therefore,insubsequentversions,thistechnologycanbecoordinatedimprovements.However,someorganizationshavedevelopedaJava-basedalternatives,tryingtomakeupforthesedeficiencies.Accordingtoourjudgment,thisiswrong.JSPandServlettechnologiestoexpandtheuseofthird-partytoolssuchasApacheStructs,isagoodidea,aslongasthetooltobringthebenefitsofcompensationtoolscanbringadditionalcomplexity.4However,insteadofattemptingtouseanon-standardtoolforJSPisnotideal.Whenselectingatechnology,manyaspectsneedtoweighfactors:standardization,portability,integration,industrysupportandtechnicalcharacteristics.JSPalternativetechnologiesfordebatealmostexclusivelyfocusedonthetechnicalcharacteristics,andportability,standardizationandintegrationisalsoveryimportant.Forexample,ServletandJSPspecificationdefinesastandardWebapplicationdirectorystructure,andprovideastandardfile(.Warfile)fordeployingWebapplications.AllJSP-compliantservermustsupportthesestandards.WecancreateafiltereffecttoanytreesServletandJSPpages,butnotfornon-standardresources.Webapplicationsecuritysettingsarethesame.Inaddition,theindustrytremendoussupportJSPandServlettechnologiestomakethesetwotechnologieshavemadetremendousprogress,thusreducingmanyofthecriticismsoftheJSP.Forexample,JSPStandardTagLibraryandJSP2.0expressionlanguagetosolve.Two,themostwidespreadcriticism:thelackofgooditerativestructure;withoutusingexplicitJavacodeorlengthyjsp:useBeanelementisdifficulttoaccessdynamicresults.Third,themisunderstandingoftheJSPForgetJSPtechnologyistheserver-sidetechnologyHerearesometypicalquestionsMartyreceived(mostoftheproblemsoccurmorethanonce).OurserverisrunningJDK1.4.HowdoIuseSwingcomponentsJSPpages?HowdoIputanimageJSPpage?IdonotknowwhattoreadimagefilesshouldJavaI/Ocommands.TomcatdoesnotsupportJavaScript,whentheusermovesthemouseovertheimage,howdoImaketheimageshighlightit?OurcustomersdonotunderstandtheJSPusingolderbrowsers.HowshouldIdo?SourceWhen(viewsourcecode),andhowtostopthemseeJSPtags?WhenourcustomersusethebrowserViewAllofthesequestionsarebasedonthebrowsertotheserverintheprocessofunderstandingtheassumptions.Butinfactbrowserdoesnotunderstandtheprocessontheserverside.Therefore:5IfyouwanttouseSwingcomponentsappletonaWebpage,itisimportantthattheJavaversionofthebrowser,andJavaversionsoftheserver-independent.IfyourbrowsersupportsJava2platform,youcanusethenormalAPPLET(orJavaplug-in)label,evenwithnon-Javatechnologyontheservershouldalsobetrue.YoudonotneedJavaI/Otoreadimagefiles,youcansimplystoretheimageonthecatalogWebresources(ieWEB-INF/classesdirectorylevelsup),andoutputsanormalIMGtag.YoushouldusetheSCRIPTtag,useclient-sideJavaScripttocreatetheimageunderthemousewillchange,andthiswillnotchangebecausetheserverusingJSP.BrowserdoesnotsupportJSP-theyseeonlytheoutputoftheJSPpage.Thus,astreatedasstaticHTMLpages,justmakesuretheoutputJSPandHTMLcompatiblebrowser.Ofcourse,youdonotneedtodoanythingtopreventcustomersseeJSPtagsthatareprocessedontheserverandsenttothecustomersoutputdoesnotappear.ConfusionduringthetransitionperiodandrequestJSPpageneedstobeconvertedintoaservlet.ServletAftercompiling,loadingthecontentserver,initializeandexecute.Butwhathappensineachstepwhen?Toanswerthisquestion,wemustrememberthefollowingpoints:JSPpagesonlywhenfirstaccessedaftermodification,willbeconvertedintoaservletandcompiled;loadedintomemory,initializationandexecutionfollowthegeneralrulesoftheservlet.Themostcommonlymisunderstoodtermhashighlightedmarked.Whenreferringtothetable,weshouldnotethattheservletgeneratedbytheJSPpagesusing_jspServicemethods(GETandPOSTrequestsarecallingthefunction),notthedoGetordoPostmethods.Similarly,forinitialization,jspInitmethodstheyuse,insteadoftheinitmethod.TheJSPpageistranslatedintoaservletcompiledServletServletloadedintoservermemorywillcalljspInitcall_jspService.Whatistheapplicationframework:Framework(framework)isareusable,semi-finishedapplicationthatcanbeusedto6producespecializedcustomprograms.Likepeople,softwareapplicationstobemoresimilaritiesthandifferences.Theyrunonsimilarmachines,thedesiredinputinformationfromthesamedevice,adisplayoutputtothesamedevice,anddatastoredintheharddiskdevicetothesame.Developmentoftraditionaldesktopapplicationdevelopersmoreaccustomedtotheidentityofthosewhocancoverapplicationdevelopmenttoolkitanddevelopmentenvironment.Frameworkapplicationframeworkbasedonthesepubliccanprovidedeveloperscanprovidereusableinfrastructureservicesfortheirproducts.Skeletonframeworkprovidesarangeofcomponentswiththefollowingcharacteristicstodevelopers:Theyhavebeenknowntoworkwellonotherprograms;Theycanalwaysusethenextproject;Theycanbeusedbyotherteamorganization;Theframeisatypicalbuildorbuyproposition.Ifyoubuildit,whenyouredoneyoullunderstandit,butbeforeyouspendmuchtimeinturnbeintegratedintoit?Ifyouwanttobuy,youhavetoovercomethelearningcurve,too,beforeyoucanuseitforworkandhavetospendmuchtime?Thereisnorightanswerhere,butmanyobserverswouldagreethatsuchaframeworklikeStrutsthandevelopedfromscratchtoprovideamoresignificantreturnoninvestment,especiallyforlargeprojects.Othertypesofframes:Notonlytheconceptualframeworkcanalsobeusedforapplicationcomponents.InotherdatawhichwehaveintroducedanumberofStrutsframeworkcanbeusedtogether.TheseincludetheLucenesearchengine,Scaffoldtoolkit,StrutsValidatorandTilestaglibrary.Andapplicationframework,thesetoolsalsoprovidesomesemi-finishedversion,canbeusedincustomcomponentsamongusers.Someframeworksarelimitedtospecificdevelopmentenvironment.Strutsandcomponentsinvolvedinthisarticleisnotso.YoucaninmanyenvironmentstodevelopStruts:VisualAgeforJava,JBuilder,Eclipse,Emacs,andevenuseTextpad.Foryourtools,ifyoucanusetodevelopJava,youcanuseittodevelopStruts.Techniquesused:7UseStrutsapplicationdevelopmentusingalotofotherbasictechniques.ThesetechniquesarenotspecifictoStruts,butforallJavawebapplicationcanuse.DevelopersusingStrutsframeworkliketohideinareassuchasHTTP,CGI,JSPandtediousdetailslikethetechnologybehind.AsaStrutsdeveloper,youdonotneedtoknowalltherelevantknowledge,butthesebasictechnologyworksmayhelpyoudesignathornyissueforcreativesolutions.HypertextTransferProtocol(HTTP):Whenmediationbetweenthetwocountries,diplomatsalwaysfollowaformalagreement.Diplomaticprotocolismainlydesignedtoavoidmisunderstandingsandpreventthebreakdownofnegotiations.Similarly,whentheneedfordialoguebetweencomputers,theyalsofollowaformalAgreement.Thisprotocoldefineshowdataistransmitted,andhowtodecodeaftertheyarrive.WebapplicationsthatusetheHTTPprotocoltotransferdatabetweenthecomputerandruntheserverprogramrunningthebrowser.ManyserverapplicationsusingotherprotocolsotherthanHTTP.Theymaintainapersistentconnectionbetweencomputers.Applicationservercanknowwhoisconnectedup,andwhentodisconnect.Becausetheyknowthateverystateoftheconnection,aswellaseverypersonusingit.Thisiscalledstatusagreement.Instead,HTTPisastatelessprotocol.HTTPServercanacceptavarietyofrequestsfromavarietyofcustomers,andprovideavarietyofresponse,eveniftheresponseisjusttosayNo.Notalotofnegotiationandconnectionpersistence,statelessprotocolcanhandlealargenumberofrequests.ThisistheInternetcanbeextendedtomanyreasonsacomputer.HTTPbecometheuniversalstandardbecauseofitssimplicity.HTTPrequestlookslikeanormaltextdocument.ThismakestheapplicationveryeasytocreateHTTPrequests.YoucaneventhroughthestandardproceduressuchasTelnettomanuallypassaHTTPrequest.WhentheHTTPresponseisreturned,itisalsoadevelopercandirectlyreadtheflattext.ThefirstlinecontainstheHTTPrequestmethod,followedbythesourceaddressandtheHTTPversionoftherequest.HTTPrequestheadersinthefirstrowbehindnow,cannotandtherecanbemultiple.HTTPheadersprovideadditionalinformationtotheserver.May8includethetypeandversionofthebrowser,acceptabledocumenttype,browsercookies,andsoon.Sevenkindsofrequestmethods,GETandPOSTarethemostused.Oncetheserverreceivestherequest,itisnecessarytogenerateaHTTPresponse.Thefirstlineofresponseiscalledthestatusline,includingtheHTTPprotocolversion,numericstate,andabriefdescriptionofthestate.Afterthestatusline,theserverwillreturnanHTTPresponseheader,similartotheHTTPrequestheader.Asmentionedabove,HTTPdoesnotmaintainstateinformationbetweenrequests.Theserveracceptstherequest,aresponse,andcontinuehappilyhandletextrequests.Becauseitissimpleandefficient,statelessprotocolisnotsuitablefortheneedtotracktheusersstateofdynamicapplications.CookiesandURLrewritingistrackinguserrequestsbetweenthetwostatesintheway.Acookieisaspecialkindofinformationpacketsstoredintheuserscomputer.URLrewritingisstoredinthepageaddressaspecialmark,Javaservercanuseittotrackusers.Thesetwomethodsarenotseamless,whichisusedinthedevelopmentofameanextraworkshouldbecarriedout.Onitsown,thestandardHTTPwebserverdoesnottransmitdynamiccontent.Itismostlyusedtolocatedocumentsrequestedresourceandreturnsthisresourceintheresponse.HeresthefilenormallyuseHypertextMarkupLanguage(HTML)W3C,HTMLformat,sothatthebrowsercandisplaythem.HTMLpagestypicallycontainhypertextconnectionstootherpages,youcanalsodisplaysomeothercontentsuchasimagesandvideo.Usersclickingonthelinkwillhaveanotherrequest,theybeginanewprocess.Standardwebserverhandlesstaticcontenthandlingitwell,butwhendealingwithdynamiccontentyouneedextrahelpmeansit.Definition:Staticcontentdirectlyfromthetextordatafiles,suchasHTMLorJPEGfiles.Thesefilescanbechangedatanytime,butbythetimethebrowserrequests,butcannotchangeautomatically.Instead,thedynamiccontentistemporarilygenerated,typically,itisaresponsetoindividualrequestsofthebrowser.CommonGatewayInterface(CGI).:ThefirstwidelyusedtogeneratedynamiccontentstandardCommonGatewayInterface(CommonGatewayInterface(CGI).CGIusingstandardoperatingsystemfeatures,suchas9environmentvariablesandstandardinputandoutput,andcreateabridgebetweenthegatewaybetweentheWebserverandthehostsystem.Otherprogramscanbeseenpassingoverthewebserverrequests,andcreateacustomizedresponse.WhenawebserverreceivesarequestforaCGIprogram,itwillruntheprogramandprovideinformationwhichitrequestsincluded.CGIprogramrunsandreturnstheoutputtotheWebserver,webserverresponseisoutputtothebrowser.CGIdefinesasetofinformationaboutwhatispassedasenvironmentvariables,andhowitwantstousethestandardinputandoutputpractice.LikewithHTTP,CGIisflexibleandeasytoimplement,andhasalargenumberofexistingCGIprograms.ThemaindrawbackisthatitmustCGIrequesttorunaprogramforeach.Thisisarelativelyexpensiveprocessingmethodforhigh-capacitysite,therearethousandsofrequestsperminute,itispossibletomakethecrashsite.AnotherdrawbackisplatformdependentCGIprograms,programsdevelopedononeplatformmaynotbeabletorunonanotherplatform.Javaservlet:SunsJavaServletplatformdirectlyaddressesthetwomaindisadvantagesofCGIprograms:First,servletprovidesbetterperformanceandresourceutilizationthanconventionalCGIprograms.Secondly,oncewritten,JAVAservletfeaturesmeanttorunanywhereintheroomwithJVMoperatingsystemislightweightmovable.Servletlookslikeatinywebserver.Itacceptstherequestandgeneratearesponse.However,differentfromconventionalwebserver,servletAPIisspecificallydesignedtohelpJavadeveloperstocreatedynamicapplications.ServletitselfistobecompiledintoJavabytecodeclass,justlikeanyotherJavaobjects.HTTPServletaccessspecificservicesAPI,butit
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 六一活动投球活动方案
- 六一活动游泳池活动方案
- 六一活动趣味性活动方案
- 六一独唱比赛活动方案
- 六一纹眉活动方案
- 六一节慰问活动方案
- 六一营销活动方案
- 六一采访活动方案
- 六五环境日小学活动方案
- 六年级英语课上活动方案
- 小学语文课前预习有效指导的研究结题报告
- 保密知识培训与教育
- 地类及变化原因划分、数据库结构、森林资源变化图斑现地核实表、年度更新统计报表
- 安全标准化示范班组建设汇报
- 材料科学基础-第9章-材料的亚稳态
- 2023(买卖合同)买卖合作协议正规范本(通用版)
- GB/T 4437.1-2023铝及铝合金热挤压管第1部分:无缝圆管
- 工贸企业重大事故隐患判定标准-处罚事故案例
- 中药贴敷课件
- 混凝土电杆组立检验批质量验收记录表
- 【中国礼仪文化在高铁乘务中的体现及提升策略8000字(论文)】
评论
0/150
提交评论