英文技术资料翻译模版文档格式.docx

上传人:b****1 文档编号:437502 上传时间:2023-04-28 格式:DOCX 页数:12 大小:35.83KB
下载 相关 举报
英文技术资料翻译模版文档格式.docx_第1页
第1页 / 共12页
英文技术资料翻译模版文档格式.docx_第2页
第2页 / 共12页
英文技术资料翻译模版文档格式.docx_第3页
第3页 / 共12页
英文技术资料翻译模版文档格式.docx_第4页
第4页 / 共12页
英文技术资料翻译模版文档格式.docx_第5页
第5页 / 共12页
英文技术资料翻译模版文档格式.docx_第6页
第6页 / 共12页
英文技术资料翻译模版文档格式.docx_第7页
第7页 / 共12页
英文技术资料翻译模版文档格式.docx_第8页
第8页 / 共12页
英文技术资料翻译模版文档格式.docx_第9页
第9页 / 共12页
英文技术资料翻译模版文档格式.docx_第10页
第10页 / 共12页
英文技术资料翻译模版文档格式.docx_第11页
第11页 / 共12页
英文技术资料翻译模版文档格式.docx_第12页
第12页 / 共12页
亲,该文档总共12页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

英文技术资料翻译模版文档格式.docx

《英文技术资料翻译模版文档格式.docx》由会员分享,可在线阅读,更多相关《英文技术资料翻译模版文档格式.docx(12页珍藏版)》请在冰点文库上搜索。

英文技术资料翻译模版文档格式.docx

AServlet'

sJob

ServletsareJavaprogramsthatrunonWeborapplicationservers,actingasamiddlelayerbetweenrequestscomingfromWebbrowsersorotherHTTPclientsanddatabasesorapplicationsontheHTTPserver.Theirjobistoperformthefollowingtasks,asillustratedinFigure1-1.

Figure1-1

1.Readtheexplicitdatasentbytheclient.

TheendusernormallyentersthisdatainanHTMLformonaWebpage.However,thedatacouldalsocomefromanappletoracustomHTTPclientprogram.

2.ReadtheimplicitHTTPrequestdatasentbythebrowser.

Figure1-1showsasinglearrowgoingfromtheclienttotheWebserver(thelayerwhereservletsandJSPexecute),buttherearereallytwovarietiesofdata:

theexplicitdatathattheenduserentersinaformandthebehind-the-scenesHTTPinformation.Bothvarietiesarecritical.TheHTTPinformationincludescookies,informationaboutmediatypesandcompressionschemesthebrowserunderstands,andsoon.

3.Generatetheresults.

Thisprocessmayrequiretalkingtoadatabase,executinganRMIorEJBcall,invokingaWebservice,orcomputingtheresponsedirectly.Yourrealdatamaybeinarelationaldatabase.Fine.Butyourdatabaseprobablydoesn'

tspeakHTTPorreturnresultsinHTML,sotheWebbrowsercan'

ttalkdirectlytothedatabase.Evenifitcould,forsecurityreasons,youprobablywouldnotwantitto.Thesameargumentappliestomostotherapplications.YouneedtheWebmiddlelayertoextracttheincomingdatafromtheHTTPstream,talktotheapplication,andembedtheresultsinsideadocument.

4.Sendtheexplicitdata.,thedocument)totheclient.

Thisdocumentcanbesentinavarietyofformats,includingtext(HTMLorXML),binary(GIFimages),orevenacompressedformatlikegzipthatislayeredontopofsomeotherunderlyingformat.But,HTMLisbyfarthemostcommonformat,soanimportantservlet/JSPtaskistowraptheresultsinsideofHTML.

5.SendtheimplicitHTTPresponsedata.

Figure1-1showsasinglearrowgoingfromtheWebmiddlelayer(theservletorJSPpage)totheclient.But,therearereallytwovarietiesofdatasent:

thedocumentitselfandthebehind-the-scenesHTTPinformation.Again,bothvarietiesarecriticaltoeffectivedevelopment.SendingHTTPresponsedatainvolvestellingthebrowserorotherclientwhattypeofdocumentisbeingreturned.,HTML),settingcookiesandcachingparameters,andothersuchtasks.

WhyBuildWebPagesDynamically?

Manyclientrequestscanbesatisfiedbyprebuiltdocuments,andtheserverwouldhandletheserequestswithoutinvokingservlets.Inmanycases,however,astaticresultisnotsufficient,andapageneedstobegeneratedforeachrequest.ThereareanumberofreasonswhyWebpagesneedtobebuilton-the-fly:

1.TheWebpageisbasedondatasentbytheclient.

Forinstance,theresultspagefromsearchenginesandorder-confirmationpagesatonlinestoresarespecifictoparticularuserrequests.Youdon'

tknowwhattodisplayuntilyoureadthedatathattheusersubmits.Justrememberthattheusersubmitstwokindsofdata:

explicit.,HTMLformdata)andimplicit.,HTTPrequestheaders).Eitherkindofinputcanbeusedtobuildtheoutputpage.Inparticular,itisquitecommontobuildauser-specificpagebasedonacookievalue.

2.TheWebpageisderivedfromdatathatchangesfrequently.

Ifthepagechangesforeveryrequest,thenyoucertainlyneedtobuildtheresponseatrequesttime.Ifitchangesonlyperiodically,however,youcoulddoittwoways:

youcouldperiodicallybuildanewWebpageontheserver(independentlyofclientrequests),oryoucouldwaitandonlybuildthepagewhentheuserrequestsit.Therightapproachdependsonthesituation,butsometimesitismoreconvenienttodothelatter:

waitfortheuserrequest.Forexample,aweatherreportornewsheadlinessitemightbuildthepagesdynamically,perhapsreturningapreviouslybuiltpageifthatpageisstilluptodate.

3.TheWebpageusesinformationfromcorporatedatabasesorotherserver-sidesources.

Iftheinformationisinadatabase,youneedserver-sideprocessingeveniftheclientisusingdynamicWebcontentsuchasanapplet.Imagineusinganappletbyitselfforasearchenginesite:

"

Downloading50terabyteapplet,pleasewait!

Obviously,thatissilly;

youneedtotalktothedatabase.GoingfromtheclienttotheWebtiertothedatabase(athree-tierapproach)insteadoffromanappletdirectlytoadatabase(atwo-tierapproach)providesincreasedflexibilityandsecuritywithlittleornoperformancepenalty.Afterall,thedatabasecallisusuallytherate-limitingstep,sogoingthroughtheWebserverdoesnotslowthingsdown.Infact,athree-tierapproachisoftenfasterbecausethemiddletiercanperformcachingandconnectionpooling.

Inprinciple,servletsarenotrestrictedtoWeborapplicationserversthathandleHTTPrequestsbutcanbeusedforothertypesofserversaswell.Forexample,servletscouldbeembeddedinFTPormailserverstoextendtheirfunctionality.And,aservletAPIforSIP(SessionInitiationProtocol)serverswasrecentlystandardized(seeen/jsr/detail?

id=116).Inpractice,however,thisuseofservletshasnotcaughton,andwe'

llonlybediscussingHTTPservlets.

TheAdvantagesofServletsOver"

Traditional"

CGI

Javaservletsaremoreefficient,easiertouse,morepowerful,moreportable,safer,andcheaperthantraditionalCGIandmanyalternativeCGI-liketechnologies.

1.Efficient

WithtraditionalCGI,anewprocessisstartedforeachHTTPrequest.IftheCGIprogramitselfisrelativelyshort,theoverheadofstartingtheprocesscandominatetheexecutiontime.Withservlets,theJavavirtualmachinestaysrunningandhandleseachrequestwithalightweightJavathread,notaheavyweightoperatingsystemprocess.Similarly,intraditionalCGI,ifthereareNrequeststothesameCGIprogram,thecodefortheCGIprogramisloadedintomemoryNtimes.Withservlets,however,therewouldbeNthreads,butonlyasinglecopyoftheservletclasswouldbeloaded.Thisapproachreducesservermemoryrequirementsandsavestimebyinstantiatingfewerobjects.Finally,whenaCGIprogramfinisheshandlingarequest,theprogramterminates.Thisapproachmakesitdifficulttocachecomputations,keepdatabaseconnectionsopen,andperformotheroptimizationsthatrelyonpersistentdata.Servlets,however,remaininmemoryevenaftertheycompletearesponse,soitisstraightforwardtostorearbitrarilycomplexdatabetweenclientrequests.

2.Convenient

ServletshaveanextensiveinfrastructureforautomaticallyparsinganddecodingHTMLformdata,readingandsettingHTTPheaders,handlingcookies,trackingsessions,andmanyothersuchhigh-levelutilities.InCGI,youhavetodomuchofthisyourself.Besides,ifyoualreadyknowtheJavaprogramminglanguage,whylearnPerltoo?

You'

realreadyconvincedthatJavatechnologymakesformorereliableandreusablecodethandoesVisualBasic,VBScript,orC++.Whygobacktothoselanguagesforserver-sideprogramming?

3.Powerful

ServletssupportseveralcapabilitiesthataredifficultorimpossibletoaccomplishwithregularCGI.ServletscantalkdirectlytotheWebserver,whereasregularCGIprogramscannot,atleastnotwithoutusingaserver-specificAPI.CommunicatingwiththeWebservermakesiteasiertotranslaterelativeURLsintoconcretepathnames,forinstance.Multipleservletscanalsosharedata,makingiteasytoimplementdatabaseconnectionpoolingandsimilarresource-sharingoptimizations.Servletscanalsomaintaininformationfromrequesttorequest,simplifyingtechniqueslikesessiontrackingandcachingofpreviouscomputations.

4.Portable

ServletsarewrittenintheJavaprogramminglanguageandfollowastandardAPI.ServletsaresupporteddirectlyorbyapluginonvirtuallyeverymajorWebserver.Consequently,servletswrittenfor,say,MacromediaJRuncanrunvirtuallyunchangedonApacheTomcat,MicrosoftInternetInformationServer(withaseparateplugin),IBMWebSphere,iPlanetEnterpriseServer,Oracle9iAS,orStarNineWebStar.TheyarepartoftheJava2Platform,EnterpriseEdition,soindustrysupportforservletsisbecomingevenmorepervasive.

5.Inexpensive

AnumberoffreeorveryinexpensiveWebserversaregoodfordevelopmentuseordeploymentoflow-ormedium-volumeWebsites.Thus,withservletsandJSPyoucanstartwithafreeorinexpensiveserverandmigratetomoreexpensiveserverswithhigh-performancecapabilitiesoradvancedadministrationutilitiesonlyafteryourprojectmeetsinitialsuccess.ThisisincontrasttomanyoftheotherCGIalternatives,whichrequireasignificantinitialinvestmentforthepurchaseofaproprietarypackage.

Priceandportabilityaresomewhatconnected.Forexample,Martytriestokeeptrackofthecountriesofreadersthatsendhimquestionsbyemail.Indiawasnearthetopofthelist,probably#2behindthe.MartyalsotaughtoneofhisJSPandservlettrainingcourses(seeinManila,andtherewasgreatinterestinservletandJSPtechnologythere.

Now,whyareIndiaandthePhilippinesbothsointerested?

Wesurmisethattheansweristwofold.First,bothcountrieshavelargepoolsofwell-educatedsoftwaredevelopers.Second,bothcountrieshave(orhad,atthattime)highlyunfavorablecurrencyexchangeratesagainstthe.dollar.So,buyingaspecial-purposeWebserverfroma.companyconsumedalargepartofearlyprojectfunds.

But,withservletsandJSP,theycouldstartwithafreeserver:

ApacheTomcat(eitherstandalone,embeddedintheregularApacheWebserver,orembeddedinMicrosoftIIS).Oncetheprojectstartstobeco

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

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

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

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