




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
文档从互联网中收集,已重新修正排版,word格式支持编辑,如有帮助欢迎下载支持。外文文献JSPTechnologyandServletsJSPprofileJSP(JavaServerPages)isinitiatedbySunMicrosystems,Inc.,withmanycompaniestoparticipateintheestablishmentofadynamicwebpagetechnicalstandards.JSPtechnologysomewhatsimilartoASPtechnology,itisinthetraditionalHTMLwebpagedocument(*.htm,*.html)toinserttheJavaprogrammingparagraph(Scriptlet)andJSPtag(tag),thusJSPdocuments(*.jsp).UsingJSPdevelopmentoftheWebapplicationiscrossthatcanrunonLinux,isalsoavailableforotheroperatingsystems.JSPtechnologytousetheJavaprogramminglanguagepreparedbythecategoryofXMLtagsandscriptlets,toproducedynamicpagespackageprocessinglogic.Pagealsovisitbytagsandscriptletsexistintheservicessideoftheresourcesoflogic.JSPpagelogicandwebpagedesignanddisplayseparation,supportreusablecomponentbaseddesign,Webbasedapplicationdevelopmentisrapidandeasy.WebserverinthefaceofvisitsJSPpagerequest,thefirstimplementationoftheproceduresof,andthentogetherwiththeresultsoftheimplementationofJSPdocumentsinHTMLcodewiththereturntothecustomer.InserttheJavaprogrammingoperationofthedatabasecanbereorientedwebsites,inordertoachievetheestablishmentofdynamicpagesneededtofunction.JSPandJavaServlet,isintheimplementationoftheserver,usuallyreturnedtotheclientisanHTMLtext,aslongastheclientbrowserwillbeabletovisit.JSP1.0specificationofthefinalversionislaunchedinSeptember1999,Decemberhasintroduced1.1specifications.AtpresentrelativelynewisJSP1.2norms,JSP2.0normsofthedrafthasalsobeenintroduced.JSPpagesfromHTMLcodeandJavacodeembeddedinoneofthecomponents.JSscriptlanguagesynopsisJSisjavascrip,JavascriptisonekindthescriptlanguagewhichcomesbytheNetscapeLiveScriptdevelopment,themainpurposeistosolvetheserverterminallanguage,forinstancePerl,carryoverspeedquestion.Atthattimeservedtheendtoneedtocarryontheconfirmationtothedata,becausethenetworkspeedwasquiteslow,onlythen28.8kbps,thecolword格式支持编辑,如有帮助欢迎下载支持。文档从互联网中收集,已重新修正排版,word格式支持编辑,如有帮助欢迎下载支持。nfirmationstepwaste'stimeweretoomany.ThereforeNetscapebrowserNavigatorhasjoinedJavascript,hasprovidedthedataconfirmationbasicfunction.TheJavaScriptofficialnameis“ECMAScript”.ThisstandardbyECMAorganizationdevelopmentandmaintenance.ECMA262istheofficialJavaScriptstandard.ThisstandardbasedonJavaScript(Netscape)andJScript(Microsoft).Netscape(Navigator2.0)BrendanEichhasinventedthislanguage,startedfrom1996,alreadyappearedinallNetscapeandintheMicrosoftbrowser.TheECMA262developmentbeganin1996,in1997July,theECMAgeneralmeetinghasaccepteditsfirstedition.Thescriptusesonespecificdescriptivelanguage,restsoncertainformcompilationtobepossibletheexecutiondocument,isalsocalledasgreatorthebatchrundocument.Thescriptusuallymaytransfertemporarilybytheapplicationprocedureandcarryout.Eachkindofscriptpresentwidelyisappliedinthehomepagedesign,becausethescriptnotonlymayreducethehomepagethescaleandraisesthehomepagebrowsingspeed,moreovermayenrichthehomepageperformance,likeanimation,soundandsoon.Citesamostcommonexample,whenweclickinthehomepagetheEmailaddresscantransferOutlookExpressortheFoxmailthiskindofmailsoftwareautomatically,isrealizesthroughthescriptfunction.Alsobecauseofscriptthesecharacteristics,thehumanwhoharborsulteriormotivesbysomeareoftenusing.Forexamplejoinssomedestructioncomputersystem'sorderinthescript,likethisworksastheuserbrowsinghomepage,oncetransfersthiskindofscript,willthencausetheuserthesystemtocomeundertheattack.Thereforetheusershouldactaccordingtovisitshomepagethetrustdegreeselectivesecurityrank,speciallyregardingtheseitselfcontentontheillegalhomepage,donotpermittheusescripteasily.Through“thesafeestablishment”thedialogbox,thechoice“thescript“underoptioneachkindofestablishmentmaywitheaserealizetoscriptbeingforbidandbeginsusing.JSPandServletsThetechnologyofJSPandServletisthemostimportanttechnologywhichuseJavatechnologytoexploitrequestofserver,anditisalsothestandardwhichexploitbusinessapplication.Javadevelopersprefertouseitforavarietyofreasons,one2word格式支持编辑,如有帮助欢迎下载支持。文档从互联网中收集,已重新修正排版,word格式支持编辑,如有帮助欢迎下载支持。ofwhichisalreadyfamiliarwiththeJavalanguageforthedevelopmentofthistechnologyareeasytolearnJavatotheotheris"apreparation,runeverywhere"tobringtheconceptofWebapplications,Toachievea"onepreparedeverywhererealized."Andmoreimportantly,iffollowedsomeoftheprinciplesofgooddesign,itcanbesaidofseparatingandcontenttocreatehighquality,reusable,easytomaintainandmodifytheapplication.Forexample,ifthedocumentinHTMLembeddedJavacodetoomuch(script),willleadthedevelopedapplicationisextremelycomplex,difficulttoread,itisnoteasyreuse,butalsoforfuturemaintenanceandmodificationwillalsocausedifficulties.Infact,CSDNtheJSP/Servletforum,canoftenseesomequestions,thecodeisverylong,canlogicisnotveryclear,alargenumberofHTMLandJavacodemixedtogether.Thisistherandomdevelopmentofthedefects.EarlydynamicpagesmainlyCGI(CommonGatewayInterface,publicGatewayInterface)technology,youcanusedifferentlanguagesoftheCGIprograms,suchasVB,C/C++orDelphi,andsoon.ThoughthetechnologyofCGIisdevelopedandpowerful,becauseofdifficultiesinprogramming,andlowefficiency,modifycomplexshortcomings,itisgraduallybeingreplacedbythetrend.Ofallthenewtechnology,JSP/Servletwithmoreefficientandeasytoprogram,morepowerful,moresecureandhasagoodportability,theyhavebeenmanypeoplebelievethatthefutureisthemostdynamicsiteofthefuturedevelopmentoftechnology.SimilartoCGI,Servletsupportrequest/responsemodel.Whenacustomersubmitarequesttotheserver,theserverpresentedtherequestServlet,Servletresponsibleforhandlingrequestsandgeneratearesponse,andthengavetheserver,andthenfromtheserversenttothecustomer.AndtheCGIisdifferent,Servletnotgenerateanewprocess,butwithHTTPServeratthesameprocess.Itthreadsthroughtheuseoftechnology,reducetheservercosts.Servlethandlingoftherequestprocessisthis:Whenreceivedfromtheclient'srequest,callingservicemethods,themethodofServletarrivalofthefirstjudgementiswhattypeofrequest(GET/POST/HEAD…),thencallstheappropriatetreatment(DoGet/doPost/doHead…)andgeneratearesponse.Althoughsuchacomplex,infact,simplysaidtoServletisaJavaclass.AndthegeneralcategoryofthedifferenceisthatthistypeoperatinginaServletcontainer,whichcanprovidesessionmanagementandtargetedlifecyclemanagement.Sot3word格式支持编辑,如有帮助欢迎下载支持。文档从互联网中收集,已重新修正排版,word格式支持编辑,如有帮助欢迎下载支持。hatwhenyouusetheServlet,youcangetallthebenefitsoftheJavaplatform,includingthesafetyofthemanagement,useJDBCaccessthedatabaseandcrossplatformcapability.Moreover,Servletusingthread,andcandevelopmoreefficientWebapplications.JSPtechnologyisakeyJ2EEtechnology,itatahigherlevelofabstractionofaServlet.ItallowsconventionalstaticanddynamicHTMLcontentgeneratedbycombininganHTMLpagelookslike,butasaServlettorun.TherearemanycommercialapplicationserversupportJSPtechnology,suchasBEAWebLogic,IBMWebSphere,JRun,andsoon.JSPandServletusemorethansimple.IfyouhaveaJSPsupportforWebservers,andaJSPdocument,youcanputitFangdaoanystaticHTMLfilescanbeplaced,donothavetocompile,donothavetopack,donothavetoClassPathsettings,youcanvisitasordinaryWebItdidvisit,theserverwillautomaticallyhelpyoutodootherwork.JSPdocumentlookslikeanordinarystaticHTMLdocument,butinsidecontainsanumberofJavacode.Ituses.Jspthesuffix,usedtotelltheserverthisdocumentinneedofspecialtreatment.WhenwevisitaJSPpage,thedocumentwillfirstbetranslatedintoaJSPengineJavasourcefiles,isactuallyaServlet,andcompiler,andthen,likeotherServlet,fromServletenginetohandle.Servletengineofthistypeloading,handlingrequestsfromcustomers,andtheresultsreturnedtothecustomer.Afteranothervisitthispagetothecustomer,aslongasthepapertherehavebeennochanges,JSPenginehasbeenloadeddirectlycalltheServlet.Ifyouhavealreadybeenmodified,itwillbeonceagaintheimplementationoftheaboveprocess,translate,compileandload.Infact,thisisthesocalled"firstpersontopunishment."Becausewhenthefirstvisittotheimplementationofaseriesoftheaboveprocess,sowillspendsometimeaftersuchavisitwouldnot.JavaservletsofferapowerfulAPIthatprovidesaccesstoalltheinformationabouttherequest,thesession,biningJSPwithservletsletsyouclearlyseparatetheapplicationlogicfromthepresentationoftheapplicationinotherwords,itletsyouusethemostappropriatecomponenttypefortherolesofModel,ViewandController.4word格式支持编辑,如有帮助欢迎下载支持。文档从互联网中收集,已重新修正排版,word格式支持编辑,如有帮助欢迎下载支持。Servlets,Filters,andListenersAservletisaJavaclassthatextendsaserverwithfunctionalityforprocessingarequestandproducingaresponse.It'simplementedusingtheclassesandinterfacesdefinedbytheServletAPI.TheAPIconsistsoftwopackages:thejavax.servletpackagecontainsclassesandinterfacesthatareprotocolindependent,whilethepackageprovidesHTTP-specificextensionsandutilityclasses.Whatmakesaservletaservletisthattheclassimplementsaninterfacenamed,eitherdirectlyorbyextendingoneofthesupportclasses.Thisinterfacedefinesthemethodsusedbythewebcontainertomanageandinteractwiththeservlet.AservletforprocessingHTTPrequeststypicallyextendstheclass.ThisclassimplementstheServletinterfaceandprovidesadditionalmethodssuitableforHTTPprocessing.ServletLifecycleThewebcontainermanagesallaspectsoftheservlet'slifecycle.Itcreatesaninstanceoftheservletclasswhenneeded,passesrequeststotheinstanceforprocessing,andeventuallyremovestheinstance.ForanHttpServlet,thecontainercallsthefollowingmethodsattheappropriatetimesintheservletlifecycle.BesidesthedoGet()anddoPost()methods,therearemethodscorrespondingtotheotherHTTPmethods:doDelete(),doHead(),doOptions(),doPut(),anddoTrace().Typicallyyoudon'timplementthesemethods;theHttpServletclassalreadytakescareofHEAD,OPTIONS,andTRACErequestsinawaythat'ssuitableformostservlets,andtheDELETEandPUTHTTPmethodsarerarelyusedinawebapplication.It'simportanttorealizethatthecontainercreatesonlyoneinstanceofeachservlet.Thismeansthattheservletmustbethreadsafe-abletohandlemultiplerequestsatthesametime,eachexecutingasaseparatethreadthroughtheservletcode.Withoutgettinglostindetails,yousatisfythisrequirementwithregardstoinstancevariablesifyoumodifythereferencedobjectsonlyintheinit()anddestroy()methods,andjustreadthemintherequestprocessingmethods.CompilingandInstallingaServlet5word格式支持编辑,如有帮助欢迎下载支持。文档从互联网中收集,已重新修正排版,word格式支持编辑,如有帮助欢迎下载支持。Tocompileaservlet,youmustfirstensurethatyouhavetheJARfilecontainingallServletAPIclassesintheCLASSPATHenvironmentvariable.TheJARfileisdistributedwithallwebcontainers.Tomcatincludesitinafilecalledservlet.jar,locatedinthecommon/libdirectory.OnaWindowsplatform,youincludetheJARfileintheCLASSPATH.ReadingaRequestOneoftheargumentspassedtothedoGet()anddoPost()methodsisanobjectthatimplementstheHttpServletRequestinterface.Thisinterfacedefinesmethodsthatprovideaccesstoawealthofinformationabouttherequest.GeneratingaResponseBesidestherequestobject,thecontainerpassesanobjectthatimplementstheHttpServletResponseinterfaceasanargumenttothedoGet()anddoPost()methods.Thisinterfacedefinesmethodsforgettingawriterorstreamfortheresponsebody.Italsodefinesmethodsforsettingtheresponsestatuscodeandheaders.UsingFiltersandListenersTheservletspecificationdefinestwocomponenttypesbesideservlets:filtersandlisteners.ThesetwotypeswereintroducedintheServlet2.3specification,soifyou'reusingacontainerthatdoesn'tyetsupportthisversionofthespecification,I'mafraidyou'reoutofluck.FiltersAfilterisacomponentthatcaninterceptarequesttargetedforaservlet,JSPpage,orstaticpage,aswellastheresponsebeforeit'ssenttotheclient.Thismakesiteasytocentralizetasksthatapplytoallrequests,suchasaccesscontrol,logging,andchargingforthecontentortheservicesofferedbytheapplication.Afilterhasfullaccesstothebodyandheadersoftherequestandresponse,soitcanalsoperformvarioustransformations.OneexampleiscompressingtheresponsebodyiftheAcceptlanguagerequestheaderindicatesthattheclientcanhandleacompressedresponse.6word格式支持编辑,如有帮助欢迎下载支持。文档从互联网中收集,已重新修正排版,word格式支持编辑,如有帮助欢迎下载支持。AfiltercanbeappliedtoeitheraspecificservletortoallrequestsmatchingaURLpattern,suchasURLsstartingwiththesamepathelementsorhavingthesameextension.ListenersListenersallowyourapplicationtoreacttocertainevents.PriortoServlet2.3,youcouldhandleonlysessionattributebindingevents(triggeredwhenanobjectwasaddedorremovedfromasession).YoucoulddothisbylettingtheobjectsavedasasessionattributimplementtheHttpSessionBindingListenerinterface.Withthenewinterfacesintroducedinthe2.3versionofthespecification,youcancreatelistenersforservletcontextandsessionlifecycleeventsaswellassessionactivationandpassivationevents(usedbyacontainerthattemporarilysavessessionstatetodiskormigratesasessiontoanotherserver).Anewsessionattributeeventlisteneralsomakesitpossibletodealwithattributebindingeventsforallsessionsinoneplace,insteadofplacingindividuallistenerobjectsineachsession.ThenewtypesoflistenersfollowthestandardJavaeventmodel.Inotherwords,alistenerisaclassthatimplementsoneormoreofthelistenerinterfaces.Theinterfacesdefinemethodsthatcorrespondtoevents.Thelistenerclassisregisteredwiththecontainerwhentheapplicationstarts,andthecontainerthencallstheeventmethodsattheappropriatetimes.InitializingSharedResourcesUsingaListenerBeanslikethistypicallyneedtobeinitializedbeforetheycanbeused.Forinstance,theymayneedareferencetoadatabaseorsomeotherexternaldatasourceandmaycreateaninitialinformationcacheinmemorytoprovidefastaccesseventothefirstrequestfordata.YoucanincludecodeforinitializationofthesharedresourcesintheservletandJSPpagesthatneedthem,butamoremodularapproachistoplaceallthiscodeinoneplaceandlettheotherpartsoftheapplicationworkontheassumptionthattheresourcesarealreadyinitializedandavailable.Anapplicationlifecyclelistenerisaperfecttoolforthistypeofresourceinitialization.Thistypeoflistenerimplementstheinterface,withmethodscalledbythecontainerwhentheapplicationstartsandwhenitshutsdown.PickingtheRightComponentTypefOrEachTask7word格式支持编辑,如有帮助欢迎下载支持。文档从互联网中收集,已重新修正排版,word格式支持编辑,如有帮助欢迎下载支持。TheProjectBillboardapplicationintroducedisafairlycomplexapplication.Halfthepagesarepurecontrollerandbusinesslogicprocessing,itaccessesadatabasetoauthenticateusers,andmostpagesrequireaccesscontrol.Inreallife,itwouldlikelycontainevenmorepages,forinstance,pagesforaccesstoashareddocumentarchive,timeschedules,andasetofpagesforadministration.Astheapplicationevolves,itmaybecomehardtomaintainasapureJSPapplication.It'seasytoforgettoincludetheaccesscontrolcodeinnewpages.ThisisclearlyanapplicationthatcanbenefitfromusingacombinationofJSPpagesandthecomponenttypesdefinedbytheservletspecificationfortheMVCroles.Let'slookatthemainrequirementsandseehowwecanmapthemtoappropriatecomponenttypes:Databaseaccessshouldbeabstracted,toavoidknowledgeofaspecificdataschemaordatabaseengineinmorethanonepartoftheapplication:beansintheroleofModelcanbeusedtoaccomplishthis.Thedatabaseaccessbeansmustbemadeavailabletoallotherpartsoftheapplicationwhenitstarts:anappli
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年城市公共自行车租赁合同示范文本
- 2025年智能机器人租赁合同违约金及赔偿标准协议
- 2025年新型建材厂房建设安全施工及环保达标合同
- 2025年绿色能源运输船舶租赁与环保责任承诺合同
- 2025年幼儿园棉被智能化采购与仓储物流管理服务协议
- 2025年高校后勤集团农产品直供与质量追溯服务合同
- 2025年新能源车贷续保服务合同范本
- 2025年度智能医疗设备投放与远程医疗服务合作协议
- 海尔冰箱安全知识培训课件
- 2025年绿色节能型办公设施销售与智能化维护综合服务合同
- 《西红柿移栽和管理》课件
- 《肺癌早期筛查与干预》课件
- 完整的离婚协议书打印电子版(2025年版)
- 自然科学类博物馆AI应用行业跨境出海战略研究报告
- 《小学科学课程标准》解读与教学设计
- 2025届高考新型题目“纠正错别字”新题模拟练习
- 2024年江苏省南京市中考数学试卷真题(含答案逐题解析)
- 儿童保健工作规范和技术规范
- 2025年区块链应用操作员职业技能竞赛理论参考试指导题库500题(含答案)
- 福建地区 绿色食品琯溪蜜柚生产操作规程
- 民办学校教职工学年度考核方案模版(3篇)
评论
0/150
提交评论