jsp技术网站设计外文翻译Word下载.docx

上传人:wj 文档编号:467692 上传时间:2023-04-29 格式:DOCX 页数:18 大小:97.65KB
下载 相关 举报
jsp技术网站设计外文翻译Word下载.docx_第1页
第1页 / 共18页
jsp技术网站设计外文翻译Word下载.docx_第2页
第2页 / 共18页
jsp技术网站设计外文翻译Word下载.docx_第3页
第3页 / 共18页
jsp技术网站设计外文翻译Word下载.docx_第4页
第4页 / 共18页
jsp技术网站设计外文翻译Word下载.docx_第5页
第5页 / 共18页
jsp技术网站设计外文翻译Word下载.docx_第6页
第6页 / 共18页
jsp技术网站设计外文翻译Word下载.docx_第7页
第7页 / 共18页
jsp技术网站设计外文翻译Word下载.docx_第8页
第8页 / 共18页
jsp技术网站设计外文翻译Word下载.docx_第9页
第9页 / 共18页
jsp技术网站设计外文翻译Word下载.docx_第10页
第10页 / 共18页
jsp技术网站设计外文翻译Word下载.docx_第11页
第11页 / 共18页
jsp技术网站设计外文翻译Word下载.docx_第12页
第12页 / 共18页
jsp技术网站设计外文翻译Word下载.docx_第13页
第13页 / 共18页
jsp技术网站设计外文翻译Word下载.docx_第14页
第14页 / 共18页
jsp技术网站设计外文翻译Word下载.docx_第15页
第15页 / 共18页
jsp技术网站设计外文翻译Word下载.docx_第16页
第16页 / 共18页
jsp技术网站设计外文翻译Word下载.docx_第17页
第17页 / 共18页
jsp技术网站设计外文翻译Word下载.docx_第18页
第18页 / 共18页
亲,该文档总共18页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

jsp技术网站设计外文翻译Word下载.docx

《jsp技术网站设计外文翻译Word下载.docx》由会员分享,可在线阅读,更多相关《jsp技术网站设计外文翻译Word下载.docx(18页珍藏版)》请在冰点文库上搜索。

jsp技术网站设计外文翻译Word下载.docx

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,whichcanprovidesessionmanagementandtargetedlife-cyclemanagement.SothatwhenyouusetheServlet,youcangetallthebenefitsoftheJavaplatform,includingthesafetyofthemanagement,useJDBCaccessthedatabaseandcross-platformcapability.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,thedocumentwillfirstbetranslatedintoa

JSPengineJavasourcefiles,isactuallyaServlet,andcompiler,andthen,likeotherServlet,fromServletenginetohandle.Servletengineofthistypeloading,handlingrequestsfromcustomers,andtheresultsreturnedtothecustomer,asshownbelow:

Figure1:

CallingtheprocessofJSPpages

Afteranothervisitthispagetothecustomer,aslongasthepapertherehavebeennochanges,JSPenginehasbeenloadeddirectlycalltheServlet.Ifyouhavealreadybeenmodified,itwillbeonceagaintheimplementationoftheaboveprocess,translate,compileandload.Infact,thisistheso-called"

firstpersontopunishment."

Becausewhenthefirstvisittotheimplementationofaseriesoftheaboveprocess,sowillspendsometimeaftersuchavisitwouldnot.

JavaservletsofferapowerfulAPIthatprovidesaccesstoalltheinformationabouttherequest,thesession,andtheapplication.combiningJSPwithservletsletsyouclearlyseparatetheapplicationlogicfromthepresentationoftheapplication;

inotherwords,itletsyouusethemostappropriatecomponenttypefortherolesofModel,ViewandController.

Servlets,Filters,andListeners

AservletisaJavaclassthatextendsaserverwithfunctionalityforprocessingarequestandproducingaresponse.It'

simplementedusingtheclassesandinterfacesdefinedbytheServletAPI.TheAPIconsistsoftwopackages:

thejavax.servletpackagecontainsclassesandinterfacesthatareprotocol-independent,whilethejavax.servlet.httppackageprovidesHTTP-specificextensionsandutilityclasses.

Whatmakesaservletaservletisthattheclassimplementsaninterfacenamedjavax.servlet.Servlet,eitherdirectlyorbyextendingoneofthesupportclasses.Thisinterfacedefinesthemethodsusedbythewebcontainertomanageandinteractwiththe

servlet.AservletforprocessingHTTPrequeststypicallyextendsthejavax.servlet.http.HttpServletclass.ThisclassimplementstheServletinterfaceandprovidesadditionalmethodssuitableforHTTPprocessing.

ServletLifecycle

Thewebcontainermanagesallaspectsoftheservlet'

slifecycle.Itcreatesaninstanceoftheservletclasswhenneeded,passesrequeststotheinstanceforprocessing,andeventuallyremovestheinstance.ForanHttpServlet,thecontainercallsthefollowingmethodsattheappropriatetimesintheservletlifecycle.

BesidesthedoGet()anddoPost()methods,therearemethodscorrespondingtotheotherHTTPmethods:

doDelete(),doHead(),doOptions(),doPut(),anddoTrace().Typicallyyoudon'

timplementthesemethods;

the HttpServletclassalreadytakescareofHEAD,OPTIONS,andTRACErequestsinawaythat'

ssuitableformostservlets,andtheDELETEandPUTHTTPmethodsarerarelyusedinawebapplication.

It'

simportanttorealizethatthecontainercreatesonlyoneinstanceof eachservlet.

Thismeansthattheservletmustbethreadsafe--abletohandlemultiplerequestsatthesametime,eachexecutingasaseparatethreadthroughtheservletcode.Withoutgettinglostindetails,yousatisfythisrequirementwithregardstoinstancevariablesifyoumodifythereferencedobjectsonlyintheinit()anddestroy()methods,andjustreadthemintherequestprocessingmethods.

CompilingandInstallingaServlet

Tocompileaservlet,youmustfirstensurethatyouhavetheJARfilecontainingallServletAPIclassesintheCLASSPATHenvironmentvariable.TheJARfileisdistributedwithallwebcontainers.Tomcatincludesitinafilecalledservlet.jar,locatedinthecommon/libdirectory.OnaWindowsplatform,youincludetheJARfileintheCLASSPATH.

.ReadingaRequest

OneoftheargumentspassedtothedoGet()anddoPost()methodsisanobjectthatimplementstheHttpServletRequestinterface.Thisinterfacedefinesmethodsthatprovideaccesstoawealthofinformationabouttherequest.

GeneratingaResponse

Besidestherequestobject,thecontainerpassesanobjectthatimplementstheHttpServletResponseinterfaceasanargumenttothedoGet()anddoPost()methods.Thisinterfacedefinesmethodsforgettingawriterorstreamfortheresponsebody.Italsodefinesmethodsforsettingtheresponsestatuscodeandheaders.

UsingFiltersandListeners

Theservletspecificationdefinestwocomponenttypesbesideservlets:

filtersandlisteners.ThesetwotypeswereintroducedintheServlet2.3specification,soifyou'

reusingacontainerthatdoesn'

tyetsupportthisversionofthespecification,I'

mafraidyou'

re

outofluck.

Filters

Afilterisacomponentthatcaninterceptarequesttargetedforaservlet,JSPpage,orstaticpage,aswellastheresponsebeforeit'

ssenttotheclient.Thismakesiteasytocentralizetasksthatapplytoallrequests,suchasaccesscontrol,logging,andchargingforthecontentortheservicesofferedbytheapplication.Afilterhasfullaccesstothebodyandheadersoftherequest andresponse,soitcanalso performvarioustransformations.OneexampleiscompressingtheresponsebodyiftheAccept-Languagerequestheaderindicatesthattheclientcanhandleacompressedresponse.

AfiltercanbeappliedtoeitheraspecificservletortoallrequestsmatchingaURLpattern,suchasURLsstartingwiththesamepathelementsorhavingthesameextension.

Listeners

Listenersallowyourapplicationtoreacttocertainevents.PriortoServlet2.3,youcouldhandleonlysessionattributebindingevents(triggeredwhenanobjectwasaddedorremovedfromasession).Youcoulddothisbylettingtheobjectsavedasasessionattribute(using the HttpSession.setAttribute() method)implement theHttpSessionBindingListenerinterface.Withthenewinterfacesintroducedinthe2.3versionofthespecification,

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

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2