




已阅读5页,还剩13页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
0外文原文JavaandtheInternetIfJavais,infact,yetanothercomputerprogramminglanguage,youmayquestionwhyitissoimportantandwhyitisbeingpromotedasarevolutionarystepincomputerprogramming.Theanswerisntimmediatelyobviousifyourecomingfromatraditionalprogrammingperspective.AlthoughJavaisveryusefulforsolvingtraditionalstandaloneprogrammingproblems,itisalsoimportantbecauseitwillsolveprogrammingproblemsontheWorldWideWeb.WhatistheWeb?TheWebcanseemabitofamysteryatfirst,withallthistalkof“surfing,”“presence,”and“homepages.”Itshelpfultostepbackandseewhatitreallyis,buttodothisyoumustunderstandclient/serversystems,anotheraspectofcomputingthatsfullofconfusingissues.Client/ServercomputingTheprimaryideaofaclient/serversystemisthatyouhaveacentralrepositoryofinformationsomekindofdata,ofteninadatabasethatyouwanttodistributeondemandtosomesetofpeopleormachines.Akeytotheclient/serverconceptisthattherepositoryofinformationiscentrallylocatedsothatitcanbechangedandsothatthosechangeswillpropagateouttotheinformationconsumers.Takentogether,theinformationrepository,thesoftwarethatdistributestheinformation,andthemachine(s)wheretheinformationandsoftwareresideiscalledtheserver.Thesoftwarethatresidesontheremotemachine,communicateswiththeserver,fetchestheinformation,processesit,andthendisplaysitontheremotemachineiscalledtheclient.Thebasicconceptofclient/servercomputing,then,isnotsocomplicated.Theproblemsarisebecauseyouhaveasingleservertryingtoservemanyclientsatonce.Generally,adatabasemanagementsystemisinvolved,sothedesigner“balances”thelayoutofdataintotablesforoptimaluse.Inaddition,systemsoftenallowaclienttoinsertnewinformationintoaserver.Thismeansyoumustensurethatoneclientsnewdatadoesntwalkoveranotherclientsnewdata,orthatdataisntlostintheprocessofaddingittothedatabase(thisis1calledtransactionprocessing).Asclientsoftwarechanges,itmustbebuilt,debugged,andinstalledontheclientmachines,whichturnsouttobemorecomplicatedandexpensivethanyoumightthink.Itsespeciallyproblematictosupportmultipletypesofcomputersandoperatingsystems.Finally,therestheall-importantperformanceissue:Youmighthavehundredsofclientsmakingrequestsofyourserveratanyonetime,soanysmalldelayiscrucial.Tominimizelatency,programmersworkhardtooffloadprocessingtasks,oftentotheclientmachine,butsometimestoothermachinesattheserversite,usingso-calledmiddleware.(Middlewareisalsousedtoimprovemaintainability.)Thesimpleideaofdistributinginformationhassomanylayersofcomplexitythatthewholeproblemcanseemhopelesslyenigmatic.Andyetitscrucial:Client/servercomputingaccountsforroughlyhalfofallprogrammingactivities.Itsresponsibleforeverythingfromtakingordersandcredit-cardtransactionstothedistributionofanykindofdatastockmarket,scientific,government,younameit.Whatwevecomeupwithinthepastisindividualsolutionstoindividualproblems,inventinganewsolutioneachtime.Thesewerehardtocreateandhardtouse,andtheuserhadtolearnanewinterfaceforeachone.Theentireclient/serverproblemneedstobesolvedinabigway.TheWebasagiantserverTheWebisactuallyonegiantclient/serversystem.Itsabitworsethanthat,sinceyouhavealltheserversandclientscoexistingonasinglenetworkatonce.Youdontneedtoknowthat,becauseallyoucareaboutisconnectingtoandinteractingwithoneserveratatime(eventhoughyoumightbehoppingaroundtheworldinyoursearchforthecorrectserver).Initiallyitwasasimpleone-wayprocess.Youmadearequestofaserverandithandedyouafile,whichyourmachinesbrowsersoftware(i.e.,theclient)wouldinterpretbyformattingontoyourlocalmachine.Butinshortorderpeoplebeganwantingtodomorethanjustdeliverpagesfromaserver.Theywantedfullclient/servercapabilitysothattheclientcouldfeedinformationbacktotheserver,forexample,tododatabaselookupsontheserver,toaddnewinformationtotheserver,ortoplaceanorder(whichrequiredmoresecuritythan2theoriginalsystemsoffered).ThesearethechangeswevebeenseeinginthedevelopmentoftheWeb.TheWebbrowserwasabigstepforward:theconceptthatonepieceofinformationcouldbedisplayedonanytypeofcomputerwithoutchange.However,browserswerestillratherprimitiveandrapidlyboggeddownbythedemandsplacedonthem.Theywerentparticularlyinteractive,andtendedtoclogupboththeserverandtheInternetbecauseanytimeyouneededtodosomethingthatrequiredprogrammingyouhadtosendinformationbacktotheservertobeprocessed.Itcouldtakemanysecondsorminutestofindoutyouhadmisspelledsomethinginyourrequest.Sincethebrowserwasjustavieweritcouldntperformeventhesimplestcomputingtasks.(Ontheotherhand,itwassafe,becauseitcouldntexecuteanyprogramsonyourlocalmachinethatmightcontainbugsorviruses.)Tosolvethisproblem,differentapproacheshavebeentaken.Tobeginwith,graphicsstandardshavebeenenhancedtoallowbetteranimationandvideowithinbrowsers.Theremainderoftheproblemcanbesolvedonlybyincorporatingtheabilitytorunprogramsontheclientend,underthebrowser.Thisiscalledclient-sideprogramming.Client-sideprogrammingTheWebsinitialserver-browserdesignprovidedforinteractivecontent,buttheinteractivitywascompletelyprovidedbytheserver.Theserverproducedstaticpagesfortheclientbrowser,whichwouldsimplyinterpretanddisplaythem.BasicHyperTextMarkupLanguage(HTML)containssimplemechanismsfordatagathering:text-entryboxes,checkboxes,radioboxes,listsanddrop-downlists,aswellasabuttonthatcanonlybeprogrammedtoresetthedataontheformor“submit”thedataontheformbacktotheserver.ThissubmissionpassesthroughtheCommonGatewayInterface(CGI)providedonallWebservers.ThetextwithinthesubmissiontellsCGIwhattodowithit.Themostcommonactionistorunaprogramlocatedontheserverinadirectorythatstypicallycalled“cgi-bin.”(IfyouwatchtheaddresswindowatthetopofyourbrowserwhenyoupushabuttononaWebpage,youcansometimessee“cgi-bin”withinallthegobbledygookthere.)Theseprogramscanbewritteninmostlanguages.Perlhasbeenacommonchoicebecauseitisdesignedfortextmanipulationandisinterpreted,soitcanbeinstalledonanyserverregardlessof3processororoperatingsystem.However,Python(myfavoriteseewww.P)hasbeenmakinginroadsbecauseofitsgreaterpowerandsimplicity.ManypowerfulWebsitestodayarebuiltstrictlyonCGI,andyoucaninfactdonearlyanythingwithCGI.However,WebsitesbuiltonCGIprogramscanrapidlybecomeoverlycomplicatedtomaintain,andthereisalsotheproblemofresponsetime.TheresponseofaCGIprogramdependsonhowmuchdatamustbesent,aswellastheloadonboththeserverandtheInternet.(Ontopofthis,startingaCGIprogramtendstobeslow.)TheinitialdesignersoftheWebdidnotforeseehowrapidlythisbandwidthwouldbeexhaustedforthekindsofapplicationspeopledeveloped.Forexample,anysortofdynamicgraphingisnearlyimpossibletoperformwithconsistencybecauseaGraphicsInterchangeFormat(GIF)filemustbecreatedandmovedfromtheservertotheclientforeachversionofthegraph.Andyouvenodoubthaddirectexperiencewithsomethingassimpleasvalidatingthedataonaninputform.Youpressthesubmitbuttononapage;thedataisshippedbacktotheserver;theserverstartsaCGIprogramthatdiscoversanerror,formatsanHTMLpageinformingyouoftheerror,andthensendsthepagebacktoyou;youmustthenbackupapageandtryagain.Notonlyisthisslow,itsinelegant.Thesolutionisclient-sideprogramming.MostmachinesthatrunWebbrowsersarepowerfulenginescapableofdoingvastwork,andwiththeoriginalstaticHTMLapproachtheyaresittingthere,justidlywaitingfortheservertodishupthenextpage.Client-sideprogrammingmeansthattheWebbrowserisharnessedtodowhateverworkitcan,andtheresultfortheuserisamuchspeedierandmoreinteractiveexperienceatyourWebsite.Theproblemwithdiscussionsofclient-sideprogrammingisthattheyarentverydifferentfromdiscussionsofprogrammingingeneral.Theparametersarealmostthesame,buttheplatformisdifferent;aWebbrowserislikealimitedoperatingsystem.Intheend,youmuststillprogram,andthisaccountsforthedizzyingarrayofproblemsandsolutionsproducedbyclient-sideprogramming.Therestofthissectionprovidesanoverviewoftheissuesandapproachesinclient-sideprogramming.4Plug-insOneofthemostsignificantstepsforwardinclient-sideprogrammingisthedevelopmentoftheplug-in.Thisisawayforaprogrammertoaddnewfunctionalitytothebrowserbydownloadingapieceofcodethatplugsitselfintotheappropriatespotinthebrowser.Ittellsthebrowser“fromnowonyoucanperformthisnewactivity.”(Youneedtodownloadtheplug-inonlyonce.)Somefastandpowerfulbehaviorisaddedtobrowsersviaplug-ins,butwritingaplug-inisnotatrivialtask,andisntsomethingyoudwanttodoaspartoftheprocessofbuildingaparticularsite.Thevalueoftheplug-inforclient-sideprogrammingisthatitallowsanexpertprogrammertodevelopanewlanguageandaddthatlanguagetoabrowserwithoutthepermissionofthebrowsermanufacturer.Thus,plug-insprovidea“backdoor”thatallowsthecreationofnewclient-sideprogramminglanguages(althoughnotalllanguagesareimplementedasplug-ins).ScriptinglanguagesPlug-insresultedinanexplosionofscriptinglanguages.Withascriptinglanguage,youembedthesourcecodeforyourclient-sideprogramdirectlyintotheHTMLpage,andtheplug-inthatinterpretsthatlanguageisautomaticallyactivatedwhiletheHTMLpageisbeingdisplayed.Scriptinglanguagestendtobereasonablyeasytounderstandand,becausetheyaresimplytextthatispartofanHTMLpage,theyloadveryquicklyaspartofthesingleserverhitrequiredtoprocurethatpage.Thetrade-offisthatyourcodeisexposedforeveryonetosee(andsteal).Generally,however,youarentdoingamazinglysophisticatedthingswithscriptinglanguages,sothisisnottoomuchofahardship.ThispointsoutthatthescriptinglanguagesusedinsideWebbrowsersarereallyintendedtosolvespecifictypesofproblems,primarilythecreationofricherandmoreinteractivegraphicaluserinterfaces(GUIs).However,ascriptinglanguagemightsolve80percentoftheproblemsencounteredinclient-sideprogramming.Yourproblemsmightverywellfitcompletelywithinthat80percent,andsincescriptinglanguagescanalloweasierandfasterdevelopment,youshouldprobablyconsiderascriptinglanguagebeforelookingatamoreinvolvedsolutionsuchasJavaorActiveXprogramming.5ThemostcommonlydiscussedbrowserscriptinglanguagesareJavaScript(whichhasnothingtodowithJava;itsnamedthatwayjusttograbsomeofJavasmarketingmomentum),VBScript(whichlookslikeVisualBASIC),andTcl/Tk,whichcomesfromthepopularcross-platformGUI-buildinglanguage.Thereareothersoutthere,andnodoubtmoreindevelopment.JavaScriptisprobablythemostcommonlysupported.ItcomesbuiltintobothNetscapeNavigatorandtheMicrosoftInternetExplorer(IE).Unfortunately,theflavorofJavaScriptonthetwobrowserscanvarywidely(theMozillabrowser,freelydownloadablefromwww.M,supportstheECMAScriptstandard,whichmayonedaybecomeuniversallysupported).Inaddition,thereareprobablymoreJavaScriptbooksavailablethantherearefortheotherbrowserlanguages,andsometoolsautomaticallycreatepagesusingJavaScript.However,ifyourealreadyfluentinVisualBASICorTcl/Tk,youllbemoreproductiveusingthosescriptinglanguagesratherthanlearninganewone.(YoullhaveyourhandsfulldealingwiththeWebissuesalready.)JavaIfascriptinglanguagecansolve80percentoftheclient-sideprogrammingproblems,whatabouttheother20percentthe“reallyhardstuff?”Javaisapopularsolutionforthis.Notonlyisitapowerfulprogramminglanguagebuilttobesecure,cross-platform,andinternational,butJavaisbeingcontinuallyextendedtoprovidelanguagefeaturesandlibrariesthatelegantlyhandleproblemsthataredifficultintraditionalprogramminglanguages,suchasmultithreading,databaseaccess,networkprogramming,anddistributedcomputing.Javaallowsclient-sideprogrammingviatheappletandwithJavaWebStart.Anappletisamini-programthatwillrunonlyunderaWebbrowser.TheappletisdownloadedautomaticallyaspartofaWebpage(justas,forexample,agraphicisautomaticallydownloaded).Whentheappletisactivated,itexecutesaprogram.Thisispartofitsbeautyitprovidesyouwithawaytoautomaticallydistributetheclientsoftwarefromtheserveratthetimetheuserneedstheclientsoftware,andnosooner.Theusergetsthelatestversionoftheclientsoftwarewithoutfailandwithoutdifficultreinstallation.BecauseofthewayJavaisdesigned,theprogrammerneedstocreateonlyasingleprogram,andthat6programautomaticallyworkswithallcomputersthathavebrowserswithbuilt-inJavainterpreters.(Thissafelyincludesthevastmajorityofmachines.)SinceJavaisafull-fledgedprogramminglanguage,youcandoasmuchworkaspossibleontheclientbeforeandaftermakingrequestsoftheserver.Forexample,youwontneedtosendarequestformacrosstheInternettodiscoverthatyouvegottenadateorsomeotherparameterwrong,andyourclientcomputercanquicklydotheworkofplottingdatainsteadofwaitingfortheservertomakeaplotandshipagraphicimagebacktoyou.Notonlydoyougettheimmediatewinofspeedandresponsiveness,butthegeneralnetworktrafficandloadonserverscanbereduced,preventingtheentireInternetfromslowingdown.OneadvantageaJavaapplethasoverascriptedprogramisthatitsincompiledform,sothesourcecodeisntavailabletotheclient.Ontheotherhand,aJavaappletcanbedecompiledwithouttoomuchtrouble,buthidingyourcodeisoftennotanimportantissue.Twootherfactorscanbeimportant.Asyouwillseelaterinthisbook,acompiledJavaappletcanrequireextratimetodownload,ifitislarge.AscriptedprogramwilljustbeintegratedintotheWebpageaspartofitstext(andwillgenerallybesmallerandreduceserverhits).ThiscouldbeimportanttotheresponsivenessofyourWebsite.Anotherfactoristheall-importantlearningcurve.Regardlessofwhatyouveheard,Javaisnotatriviallanguagetolearn.IfyoureaVISUALBASICprogrammer,movingtoVBScriptwillbeyourfastestsolution(assumingyoucanconstrainyourcustomerstoWindowsplatforms),andsinceitwillprobablysolvemosttypicalclient/serverproblems,youmightbehardpressedtojustifylearningJava.IfyoureexperiencedwithascriptinglanguageyouwillcertainlybenefitfromlookingatJavaScriptorVBScriptbeforecommittingtoJava,becausetheymightfityourneedshandilyandyoullbemoreproductivesooner.SecurityAutomaticallydownloadingandrunningprogramsacrosstheInternetcansoundlikeavirus-buildersdream.IfyouclickonaWebsite,youmightautomaticallydownloadanynumberofthingsalongwiththeHTMLpage:GIFfiles,scriptcode,compiledJavacode,andActiveXcomponents.Someofthesearebenign;GIFfilescantdoanyharm,andscriptinglanguagesaregenerallylimitedinwhattheycando.Javawasalsodesignedtorunitsapplets7withina“sandbox”ofsafety,whichpreventsitfromwritingtodiskoraccessingmemoryoutsidethesandbox.MicrosoftsActiveXisattheoppositeendofthespectrum.ProgrammingwithActiveXislikeprogrammingWindowsyoucandoanythingyouwant.SoifyouclickonapagethatdownloadsanActiveXcomponent,thatcomponentmightcausedamagetothefilesonyourdisk.Ofcourse,programsthatyouloadontoyourcomputerthatarenotrestrictedtorunninginsideaWebbrowsercandothesamething.VirusesdownloadedfromBulletin-BoardSystems(BBSs)havelongbeen.Thesolutionseemstobe“digitalsignatures,”wherebycodeisverifiedtoshowwhotheauthoris.Thisisbasedontheideathatavirusworksbecauseitscreatorcanbeanonymous,soifyouremovetheanonymity,individualswillbeforcedtoberesponsiblefortheiractions.Thisseemslikeagoodplanbecauseitallowsprogramstobemuchmorefunctional,andIsuspectitwilleliminatemaliciousmischief.If,however,aprogramhasanunintentionaldestructivebug,itwillstillcauseproblems.TheJavaapproachistopreventtheseproblemsfromoccurring,viathesandbox.TheJavainterpreterthatlivesonyourlocalWebbrowserexaminestheappletforanyuntowardinstructionsastheappletisbeingloaded.Inparticular,theappletcannotwritefilestodiskorerasefiles(oneofthemainstaysofviruses).Appletsaregenerallyconsideredtobesafe,andsincethisisessentialforreliableclient/serversystems,anybugsintheJavalanguagethatallowvirusesarerapidlyrepaired.(Itsworthnotingthatthebrowsersoftwareactuallyenforcesthesesecurityrestrictions,andsomebrowsersallowyoutoselectdifferentsecuritylevelstoprovidevaryingdegreesofaccesstoyoursystem.)Youmightbeskepticalofthisratherdraconianrestrictionagainstwritingfilestoyourlocaldisk.Forexample,youmaywanttobuildalocaldatabaseorsavedataforlateruseoffline.Theinitialvisionseemedtobethateventuallyeveryonewouldgetonlinetodoanythingimportant,butthatwassoonseentobeimpractical(althoughlow-cost“Internetappliances”mightsomedaysatisfytheneedsofasignificantsegmentofusers).Thesolutionisthe“signedapplet”thatusespublic-keyencryptiontoverifythatanappletdoesindeedcomefromwhereitclaimsitdoes.Asignedappletcanstilltrashyourdisk,butthetheoryis8thatsinceyoucannowholdtheappletcreatorsaccountable,theywontdoviciousthings.Javaprovidesaframeworkfordigitalsignaturessothatyouwilleventuallybeabletoallowanapplettostepoutsidethesandboxifnecessary.Chapter14containsanexampleofhowtosignanapplet.Inaddition,JavaWebStartisarelativelynewwaytoeasilydistributestandaloneprogramsthatdontneedawebbrowserinwhichtorun.Thistechnologyhasthepotentialofsolvingmanyclientsideproblemsassociatedwithrunningprogramsinsideabrowser.WebStartprogramscaneitherbesigned,ortheycanasktheclientforpermissioneverytimetheyaredoingsomethingpotentiallydangerousonthelocalsystem.Chapter14hasasimpleexampleandexplanationofJavaWebStart.Digitalsignatureshavemissedanimportantissue,whichisthespeedthatpeoplemovearoundontheInternet.Ifyoudownloadabuggyprogramanditdoessomethinguntoward,howlongwillitbebeforeyoudiscoverthedamage?Itcouldbedaysorevenweeks.Bythen,howwillyoutrackdowntheprogramthatsdoneit?Andwhatgoodwillitdoyouatthatpoint?IranetTheWebisthemostgeneralsolutiontotheclient/serverproblem,soitmakessensetousethesametechnologytosolveasubsetoftheproblem,inparticulartheclassicclient/serverproblemwithinacompany.Withtraditionalclient/serverapproachesyouhavetheproblemofmultipletypesofclientcomputers,aswellasthedifficultyofinstallingnewclientsoftware,bothofwhicharehandilysolvedwithWebbrowsersandclient-sideprogramming.WhenWebtechnologyisusedforaninformationnetworkthatisrestrictedtoaparticularcompany,itisreferredtoasanintranet.IntranetsprovidemuchgreatersecuritythantheInternet,sinceyoucanphysicallycontrolaccesstotheserverswithinyourcompany.Intermsoftraining,itseemsthatoncepeopleunderstandthegeneralconceptofabrowseritsmucheasierforthemtodealwithdifferencesinthewaypagesandappletslook,sothelearningcurvefornewkindsofsystemsseemstobereduced.Thesecurityproblembringsustooneofthedivisionsthatseemstobeautomaticallyformingintheworldofclient-sideprogramming.IfyourprogramisrunningontheInternet,9youdontknowwhatplatformitwillbeworkingunder,andyouwanttobeextracarefulthatyoudontdisseminatebuggycode.Youneedsomethingcross-platformandsecure,likeascriptinglanguageorJava.Ifyourerunningonanintranet,youmighthaveadifferentsetofconstraints.ItsnotuncommonthatyourmachinescouldallbeIntel/Windowsplatforms.Onanintranet,youreresponsibleforthequalityofyourowncodeandcanrepairbugswhentheyredis
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年牛老师综合技术服务合同下载
- 2025年35KV变电站安全防护设施安装工程合同
- 2025年按揭房产转租与使用权转让综合服务协议
- 2025年度www.lianjia.comzhuantijy房产经纪佣金分成合同
- 二零二五年度智能仓储与20XX货物运输一体化合同
- 团支部志愿者活动方案
- 推进区域物流协调发展方案
- 安保队主管岗位职责
- 仓库部门工作方案
- 校园活动方案策划怎么写
- 用柴油管理制度
- 《SketchUp草图大师教学》课件
- 排水管道检测与评估课件 项目2 排水管道检测基础知识
- 阅读疗法创新发展
- 第二十章手术减肥及体形塑造美容手术美容外科学概论讲解
- 中华人民共和国内河交通安全管理条例
- 工程施工质量检验试验计划
- 厨房小吃承包合同
- 特种设备之行车、吊装安全操作培训
- 初中道德与法治课堂中开展议题式教学
- 产品痛点及解决方案
评论
0/150
提交评论