英文文献及翻译Servlet及JSP技术简述.doc

上传人:工**** 文档编号:559283917 上传时间:2024-02-14 格式:DOC 页数:17 大小:107KB
返回 下载 相关 举报
英文文献及翻译Servlet及JSP技术简述.doc_第1页
第1页 / 共17页
英文文献及翻译Servlet及JSP技术简述.doc_第2页
第2页 / 共17页
英文文献及翻译Servlet及JSP技术简述.doc_第3页
第3页 / 共17页
英文文献及翻译Servlet及JSP技术简述.doc_第4页
第4页 / 共17页
英文文献及翻译Servlet及JSP技术简述.doc_第5页
第5页 / 共17页
点击查看更多>>
资源描述

《英文文献及翻译Servlet及JSP技术简述.doc》由会员分享,可在线阅读,更多相关《英文文献及翻译Servlet及JSP技术简述.doc(17页珍藏版)》请在金锄头文库上搜索。

1、英文文件及翻译Servlet及JSP技术简述AnOverviewofServletandJSPTechnologyNagle,WiegleyAbstract:Servletprogramrunningintheserver-side,dynamicallygeneratedWebpagewiththetraditionalCGIandmanyothersimilarcomparedtoCGItechnology,JavaServletwithamoreefficient,easiertouse,morepowerfulandhasbetterportability,moresavingstoi

2、nvest.Keywords:JSPTechnology;Servlet;HTTPserver1.AServletsJobServletsareJavaprogramsthatrunonWeborapplicationservers,actingasamiddlelayerbetweenrequestscomingfromWebbrowsersorotherHTTPclientsanddatabasesorapplicationsontheHTTPserver.Theirjobistoperformthefollowingtasks,asillustratedinFigure1-1.1.1Re

3、adtheexplicitdatasentbytheclient.TheendusernormallyentersthisdatainanHTMLformonaWebpage.However,thedatacouldalsocomefromanappletoracustomHTTPclientprogram.1.2ReadtheimplicitHTTPrequestdatasentbythebrowser.Figure1-1showsasinglearrowgoingfromtheclienttotheWebserver(thelayerwhereservletsandJSPexecute),

4、buttherearereallytwovarietiesofdata:theexplicitdatathattheenduserentersinaformandthebehind-the-scenesHTTPinformation.Bothvarietiesarecritical.TheHTTPinformationincludescookies,informationaboutmediatypesandcompressionschemesthebrowserunderstands,andsoon.1.3Generatetheresults.Thisprocessmayrequiretalk

5、ingtoadatabase,executinganRMIorEJBcall,invokingaWebservice,orcomputingtheresponsedirectly.Yourrealdatamaybeinarelationaldatabase.Fine.ButyourdatabaseprobablydoesntspeakHTTPorreturnresultsinHTML,sotheWebbrowsercanttalkdirectlytothedatabase.Evenifitcould,forsecurityreasons,youprobablywouldnotwantitto.

6、Thesameargumentappliestomostotherapplications.YouneedtheWebmiddlelayertoextracttheresultsinsideadocument.1.4Sendtheexplicitdata(i.e.,thedocument)totheclient.Thisdocumentcanbesentinavarietyofformats,includingtext(HTMLorXML),binary(GIFimages),orevenacompressedformatlikegzipthatislayeredontopofsomeothe

7、runderlyingformat.But,HTMLisbyfarthemostcommonformat,soanimportantservlet/JSPtaskistowraptheresultsinsideofHTML.1.5SendtheimplicitHTTPresponsedata.Figure1-1showsasinglearrowgoingfromtheWebmiddlelayer(theservletorJSPpage)totheclient.But,therearereallytwovarietiesofdatasent:thedocumentitselfandthebehi

8、nd-the-scenesHTTPinformation.Again,bothvarietiesarecriticaltoeffectivedevelopment.SendingHTTPresponsedatainvolvestellingthebrowserorotherclientwhattypeofdocumentisbeingreturned(e.g.,HTML),settingcookiesandcachingparameters,andothersuchtasks.2WhyBuildWebPagesDynamically?manyclientrequestscanbesatisfi

9、edbyprebuiltdocuments,andtheserverwouldhandletheserequestswithoutinvokingservlets.Inmanycases,however,astaticresultisnotsufficient,andapageneedstobegeneratedforeachrequest.ThereareanumberofreasonswhyWebpagesneedtobebuilton-the-fly:2.1TheWebpageisbasedondatasentbytheclient.Forinstance,theresultspagef

10、romsearchenginesandorder-confirmationpagesatonlinestoresarespecifictoparticularuserrequests.Youdontknowwhattodisplayuntilyoureadthedatathattheusersubmits.Justrememberthattheusersubmitstwokindsofdata:explicit(i.e.,HTMLformdata)andimplicit(i.e.,HTTPrequestheaders).Eitherkindofinputcanbeusedtobuildtheo

11、utputpage.Inparticular,itisquitecommontobuildauser-specificpagebasedonacookievalue.2.2TheWebpageisderivedfromdatathatchangesfrequently.Ifthepagechangesforeveryrequest,thenyoucertainlyneedtobuildtheresponseatrequesttime.Ifitchangesonlyperiodically,however,youcoulddoittwoways:youcouldperiodicallybuild

12、anewWebpageontheserver(independentlyofclientrequests),oryoucouldwaitandonlybuildthepagewhentheuserrequestsit.Therightapproachdependsonthesituation,butsometimesitismoreconvenienttodothelatter:waitfortheuserrequest.Forexample,aweatherreportornewsheadlinessitemightbuildthepagesdynamically,perhapsreturn

13、ingapreviouslybuiltpageifthatpageisstilluptodate.2.3TheWebpageusesinformationfromcorporatedatabasesorotherserver-sidesources.Iftheinformationisinadatabase,youneedserver-sideprocessingeveniftheclientisusingdynamicWebcontentsuchasanapplet.Imagineusinganappletbyitselfforasearchenginesite:Downloading50t

14、erabyteapplet,pleasewait!Obviously,thatissilly;youneedtotalktothedatabase.GoingfromtheclienttotheWebtiertothedatabase(athree-tierapproach)insteadoffromanappletdirectlytoadatabase(atwo-tierapproach)providesincreasedflexibilityandsecuritywithlittleornoperformancepenalty.Afterall,thedatabasecallisusual

15、lytherate-limitingstep,sogoingthroughtheWebserverdoesnotslowthingsdown.Infact,athree-tierapproachisoftenfasterbecausethemiddletiercanperformcachingandconnectionpooling.3TheAdvantagesofServletsOverTraditionalCGIJavaservletsaremoreefficient,safer,andcheaperthantraditionaleasiertouse,morepowerful,moreportable,CGIandmanyalternativeCGI-liketechnologies.3.1EfficientWithtraditionalCGI,anewprocessisstartedforeachHTTPrequest.IftheCGIprogramitselfisrelativelyshort,theoverheadofstartingtheprocesscandominatetheexecutiontime

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号