JSP技术----外文文献(共9页).docx

上传人:飞****2 文档编号:14158080 上传时间:2022-05-03 格式:DOCX 页数:9 大小:32.63KB
返回 下载 相关 举报
JSP技术----外文文献(共9页).docx_第1页
第1页 / 共9页
JSP技术----外文文献(共9页).docx_第2页
第2页 / 共9页
点击查看更多>>
资源描述

《JSP技术----外文文献(共9页).docx》由会员分享,可在线阅读,更多相关《JSP技术----外文文献(共9页).docx(9页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、精选优质文档-倾情为你奉上外文文献JSPTechnology andServletsJSP profileJSP(JavaServerPages)isinitiatedbySunMicrosystems,Inc.,withmanycompaniestoparticipateintheestablishmentofadynamicwebpagetechnicalstandards.JSPtechnologysomewhatsimilartoASPtechnology,itisinthetraditionalHTMLwebpagedocument(*.htm,*.html)toinserttheJ

2、avaprogrammingparagraph(Scriptlet)andJSPtag(tag),thusJSPdocuments(*.jsp).UsingJSPdevelopmentoftheWebapplicationiscrossthatcanrunonLinux,isalsoavailableforotheroperatingsystems.JSPtechnologytousetheJavaprogramminglanguagepreparedbythecategoryofXMLtagsandscriptlets,toproducedynamicpagespackageprocessi

3、nglogic.Pagealsovisitbytagsandscriptletsexistintheservicessideoftheresourcesoflogic.JSPpagelogicandwebpagedesignanddisplayseparation,supportreusablecomponent-baseddesign,Web-basedapplicationdevelopmentisrapidandeasy.WebserverinthefaceofvisitsJSPpagerequest,thefirstimplementationoftheproceduresof,and

4、thentogetherwiththeresultsoftheimplementationofJSPdocumentsinHTMLcodewiththereturntothecustomer.InserttheJavaprogrammingoperationofthedatabasecanbereorientedwebsites,inordertoachievetheestablishmentofdynamicpagesneededtofunction.JSPandJavaServlet,isintheimplementationoftheserver,usuallyreturnedtothe

5、clientisanHTMLtext,aslongastheclientbrowserwillbeabletovisit.JSP1.0specificationofthefinalversionislaunchedinSeptember1999,Decemberhasintroduced1.1specifications.AtpresentrelativelynewisJSP1.2norms,JSP2.0normsofthedrafthasalsobeenintroduced.JSPpagesfromHTMLcodeandJavacodeembeddedinoneofthecomponents

6、.JSscriptlanguagesynopsisJSisjavascrip,JavascriptisonekindthescriptlanguagewhichcomesbytheNetscapeLiveScriptdevelopment,themainpurposeistosolvetheserverterminallanguage,forinstancePerl,carry-overspeedquestion.Atthattimeservedtheendtoneedtocarryontheconfirmationtothedata,becausethenetworkspeedwasquit

7、eslow,onlythen28.8kbps,theconfirmationstepwastestimeweretoomany.ThereforeNetscapebrowserNavigatorhasjoinedJavascript,hasprovidedthedataconfirmationbasicfunction.TheJavaScriptofficialnameis“ECMAScript”.ThisstandardbyECMAorganizationdevelopmentandmaintenance.ECMA262istheofficialJavaScriptstandard.This

8、standardbasedonJavaScript(Netscape)andJScript(Microsoft).Netscape(Navigator2.0)BrendanEichhasinventedthislanguage,startedfrom1996,alreadyappearedinallNetscapeandintheMicrosoftbrowser.TheECMA262developmentbeganin1996,in1997July,theECMAgeneralmeetinghasaccepteditsfirstedition.Thescriptusesonespecificd

9、escriptivelanguage,restsoncertainformcompilationtobepossibletheexecutiondocument,isalsocalledasgreatorthebatchrundocument.Thescriptusuallymaytransfertemporarilybytheapplicationprocedureandcarryout.Eachkindofscriptpresentwidelyisappliedinthehomepagedesign,becausethescriptnotonlymayreducethehomepageth

10、escaleandraisesthehomepagebrowsingspeed,moreovermayenrichthehomepageperformance,likeanimation,soundandsoon.Citesamostcommonexample,whenweclickinthehomepagetheEmailaddresscantransferOutlookExpressortheFoxmailthiskindofmailsoftwareautomatically,isrealizesthroughthescriptfunction.Alsobecauseofscriptthe

11、secharacteristics,thehumanwhoharborsulteriormotivesbysomeareoftenusing.Forexamplejoinssomedestructioncomputersystemsorderinthescript,likethisworksastheuserbrowsinghomepage,oncetransfersthiskindofscript,willthencausetheuserthesystemtocomeundertheattack.Thereforetheusershouldactaccordingtovisitshomepa

12、gethetrustdegreeselectivesecurityrank,speciallyregardingtheseitselfcontentontheillegalhomepage,donotpermittheusescripteasily.Through“thesafeestablishment”thedialogbox,thechoice“thescript”underoptioneachkindofestablishmentmaywitheaserealizetoscriptbeingforbidandbeginsusing.JSPandServletsThetechnology

13、ofJSPandServletisthemostimportanttechnologywhichuseJavatechnologytoexploitrequestofserver,anditisalsothestandardwhichexploitbusinessapplication.Javadevelopersprefertouseitforavarietyofreasons,oneofwhichisalreadyfamiliarwiththeJavalanguageforthedevelopmentofthistechnologyareeasytolearnJavatotheotheri

14、sapreparation,runeverywheretobringtheconceptofWebapplications,Toachieveaone-preparedeverywhererealized.Andmoreimportantly,iffollowedsomeoftheprinciplesofgooddesign,itcanbesaidofseparatingandcontenttocreatehigh-quality,reusable,easytomaintainandmodifytheapplication.Forexample,ifthedocumentinHTMLembed

15、dedJavacodetoomuch(script),willleadthedevelopedapplicationisextremelycomplex,difficulttoread,itisnoteasyreuse,butalsoforfuturemaintenanceandmodificationwillalsocausedifficulties.Infact,CSDNtheJSP/Servletforum,canoftenseesomequestions,thecodeisverylong,canlogicisnotveryclear,alargenumberofHTMLandJava

16、codemixedtogether.Thisistherandomdevelopmentofthedefects.EarlydynamicpagesmainlyCGI(CommonGatewayInterface,publicGatewayInterface)technology,youcanusedifferentlanguagesoftheCGIprograms,suchasVB,C/C+orDelphi,andsoon.ThoughthetechnologyofCGIisdevelopedandpowerful,becauseofdifficultiesinprogramming,and

17、lowefficiency,modifycomplexshortcomings,itisgraduallybeingreplacedbythetrend.Ofallthenewtechnology,JSP/Servletwithmoreefficientandeasytoprogram,morepowerful,moresecureandhasagoodportability,theyhavebeenmanypeoplebelievethatthefutureisthemostdynamicsiteofthefuturedevelopmentoftechnology.SimilartoCGI,

18、Servletsupportrequest/responsemodel.Whenacustomersubmitarequesttotheserver,theserverpresentedtherequestServlet,Servletresponsibleforhandlingrequestsandgeneratearesponse,andthengavetheserver,andthenfromtheserversenttothecustomer.AndtheCGIisdifferent,Servletnotgenerateanewprocess,butwithHTTPServeratth

19、esameprocess.Itthreadsthroughtheuseoftechnology,reducetheservercosts.Servlethandlingoftherequestprocessisthis:Whenreceivedfromtheclientsrequest,callingservicemethods,themethodofServletarrivalofthefirstjudgementiswhattypeofrequest(GET/POST/HEAD),thencallstheappropriatetreatment(DoGet/doPost/doHead)an

20、dgeneratearesponse.Althoughsuchacomplex,infact,simplysaidtoServletisaJavaclass.AndthegeneralcategoryofthedifferenceisthatthistypeoperatinginaServletcontainer,whichcanprovidesessionmanagementandtargetedlifecyclemanagement.SothatwhenyouusetheServlet,youcangetallthebenefitsoftheJavaplatform,includingth

21、esafetyofthemanagement,useJDBCaccessthedatabaseandcrossplatformcapability.Moreover,Servletusingthread,andcandevelopmoreefficientWebapplications.JSPtechnologyisakeyJ2EEtechnology,itatahigherlevelofabstractionofaServlet.ItallowsconventionalstaticanddynamicHTMLcontentgeneratedbycombininganHTMLpagelooks

22、like,butasaServlettorun.TherearemanycommercialapplicationserversupportJSPtechnology,suchasBEAWebLogic,IBMWebSphere,JRun,andsoon.JSPandServletusemorethansimple.IfyouhaveaJSPsupportforWebservers,andaJSPdocument,youcanputitFangdaoanystaticHTMLfilescanbeplaced,donothavetocompile,donothavetopack,donothav

23、etoClassPathsettings,youcanvisitasordinaryWebItdidvisit,theserverwillautomaticallyhelpyoutodootherwork.JSPdocumentlookslikeanordinarystaticHTMLdocument,butinsidecontainsanumberofJavacode.Ituses.Jspthesuffix,usedtotelltheserverthisdocumentinneedofspecialtreatment.WhenwevisitaJSPpage,thedocumentwillfi

24、rstbetranslatedintoaJSPengineJavasourcefiles,isactuallyaServlet,andcompiler,andthen,likeotherServlet,fromServletenginetohandle.Servletengineofthistypeloading,handlingrequestsfromcustomers,andtheresultsreturnedtothecustomer.Afteranothervisitthispagetothecustomer,aslongasthepapertherehavebeennochanges

25、,JSPenginehasbeenloadeddirectlycalltheServlet.Ifyouhavealreadybeenmodified,itwillbeonceagaintheimplementationoftheaboveprocess,translate,compileandload.Infact,thisistheso-calledfirstpersontopunishment.Becausewhenthefirstvisittotheimplementationofaseriesoftheaboveprocess,sowillspendsometimeaftersucha

26、visitwouldnot.JavaservletsofferapowerfulAPIthatprovidesaccesstoalltheinformationabouttherequest,thesession,biningJSPwithservletsletsyouclearlyseparatetheapplicationlogicfromthepresentationoftheapplication;inotherwords,itletsyouusethemostappropriatecomponenttypefortherolesofModel,ViewandController.Se

27、rvlets,Filters,andListenersAservletisaJavaclassthatextendsaserverwithfunctionalityforprocessingarequestandproducingaresponse.ItsimplementedusingtheclassesandinterfacesdefinedbytheServletAPI.TheAPIconsistsoftwopackages:thejavax.servletpackagecontainsclassesandinterfacesthatareprotocolindependent,whil

28、ethejavax.servlet.httppackageprovidesHTTP-specificextensionsandutilityclasses.Whatmakesaservletaservletisthattheclassimplementsaninterfacenamedjavax.servlet.Servlet,eitherdirectlyorbyextendingoneofthesupportclasses.Thisinterfacedefinesthemethodsusedbythewebcontainertomanageandinteractwiththe servlet

29、.AservletforprocessingHTTPrequeststypicallyextendsthejavax.servlet.http.HttpServletclass.ThisclassimplementstheServletinterfaceandprovidesadditionalmethodssuitableforHTTPprocessing.ServletLifecycleThewebcontainermanagesallaspectsoftheservletslifecycle.Itcreatesaninstanceoftheservletclasswhenneeded,p

30、assesrequeststotheinstanceforprocessing,andeventuallyremovestheinstance.ForanHttpServlet,thecontainercallsthefollowingmethodsattheappropriatetimesintheservletlifecycle.BesidesthedoGet()anddoPost()methods,therearemethodscorrespondingtotheotherHTTPmethods:doDelete(),doHead(),doOptions(),doPut(),anddoT

31、race().Typicallyyoudontimplementthesemethods;theHttpServletclassalreadytakescareofHEAD,OPTIONS,andTRACErequestsinawaythatssuitableformostservlets,andtheDELETEandPUTHTTPmethodsarerarelyusedinawebapplication.Itsimportanttorealizethatthecontainercreatesonlyoneinstanceofeachservlet.Thismeansthattheservl

32、etmustbethreadsafe-abletohandlemultiplerequestsatthesametime,eachexecutingasaseparatethreadthroughtheservletcode.Withoutgettinglostindetails,yousatisfythisrequirementwithregardstoinstancevariablesifyoumodifythereferencedobjectsonlyintheinit()anddestroy()methods,andjustreadthemintherequestprocessingm

33、ethods.CompilingandInstallingaServletTocompileaservlet,youmustfirstensurethatyouhavetheJARfilecontainingallServletAPIclassesintheCLASSPATHenvironmentvariable.TheJARfileisdistributedwithallwebcontainers.Tomcatincludesitinafilecalledservlet.jar,locatedinthecommon/libdirectory.OnaWindowsplatform,youinc

34、ludetheJARfileintheCLASSPATH.ReadingaRequestOneoftheargumentspassedtothedoGet()anddoPost()methodsisanobjectthatimplementstheHttpServletRequestinterface.Thisinterfacedefinesmethodsthatprovideaccesstoawealthofinformationabouttherequest.GeneratingaResponseBesidestherequestobject,thecontainerpassesanobj

35、ectthatimplementstheHttpServletResponseinterfaceasanargumenttothedoGet()anddoPost()methods.Thisinterfacedefinesmethodsforgettingawriterorstreamfortheresponsebody.Italsodefinesmethodsforsettingtheresponsestatuscodeandheaders.UsingFiltersandListenersTheservletspecificationdefinestwocomponenttypesbesid

36、eservlets:filtersandlisteners.ThesetwotypeswereintroducedintheServlet2.3specification,soifyoureusingacontainerthatdoesntyetsupportthisversionofthespecification,Imafraidyoure outofluck.FiltersAfilterisacomponentthatcaninterceptarequesttargetedforaservlet,JSPpage,orstaticpage,aswellastheresponsebefore

37、itssenttotheclient.Thismakesiteasytocentralizetasksthatapplytoallrequests,suchasaccesscontrol,logging,andchargingforthecontentortheservicesofferedbytheapplication.Afilterhasfullaccesstothebodyandheadersoftherequestandresponse,soitcanalsoperformvarioustransformations.Oneexampleiscompressingtherespons

38、ebodyifthe Acceptlanguagerequestheaderindicatesthattheclientcanhandleacompressedresponse.AfiltercanbeappliedtoeitheraspecificservletortoallrequestsmatchingaURLpattern,suchasURLsstartingwiththesamepathelementsorhavingthesameextension.ListenersListenersallowyourapplicationtoreacttocertainevents.Priort

39、oServlet2.3,youcouldhandleonlysessionattributebindingevents(triggeredwhenanobjectwasaddedorremovedfromasession).Youcoulddothisbylettingtheobjectsavedasasessionattributimplementthe HttpSessionBindingListenerinterface.Withthenewinterfacesintroducedinthe2.3versionofthespecification,youcancreatelistener

40、sforservletcontextandsessionlifecycleeventsaswellassessionactivationandpassivationevents(usedbyacontainerthattemporarilysavessessionstatetodiskormigratesasessiontoanotherserver).Anewsessionattributeeventlisteneralsomakesitpossibletodealwithattributebindingeventsforallsessionsinoneplace,insteadofplac

41、ingindividuallistenerobjectsineachsession.ThenewtypesoflistenersfollowthestandardJavaeventmodel.Inotherwords,alistenerisaclassthatimplementsoneormoreofthelistenerinterfaces.Theinterfacesdefinemethodsthatcorrespondtoevents.Thelistenerclassisregisteredwiththecontainerwhentheapplicationstarts,andthecontainerthencallstheeventmethodsattheappropriatetimes.InitializingSharedResourcesUsingaListenerBeanslikethistypicallyneedtobeinitializedbeforetheycanbeused.Forin

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁