JAVA外文文献+翻译.docx
JavaandtheInternetIfJavais,infact,yetanothercomputerprogramming1anguage,youmayquestionwhyitissoimportantandwhyitisbeingpromotedasarevo1utionarystepincomputerprogramming.Theanswerisn,timmediate1yobviousifyou'recomingfromatraditiona1programmingperspective.A1thoughJavaisveryusefu1forso1vingtraditiona1stand-a1oneprogrammingprob1ems,itisa1soimportantbecauseitwi11so1veprogrammingprob1emsontheWor1dWideWeb.X.C1ient-sideprogrammingTheWeb,sinitia1server-browserdesignprovidedforinteractivecontent,buttheinteractivitywascomp1ete1yprovidedbytheserver.Theserverproducedstaticpagesforthec1ientbrowser,whichwou1dsimp1yinterpretanddisp1aythem.BasicHTM1containssimp1emechanismsfordatagathering:text-entryboxes,checkboxes,radioboxes,1istsanddrop-down1ists,aswe11asabuttonthatcanon1ybeprogrammedtoresetthedataontheformor“submit”thedataontheformbacktotheserver.ThissubmissionpassesthroughtheCommonGatewayInterface(CGI)providedona11Webservers.Thetextwithinthesubmissionte11sCGIwhattodowithit.Themostcommonactionistorunaprogram1ocatedontheserverinadirectorythat,stypica11yca11ed“cgi-bin.”(IfyouwatchtheaddresswindowatthetopofyourbrowserwhenyoupushabuttononaWebpage,youcansometimessee“cgi-bin''withina11thegobb1edygookthere.)Theseprogramscanbewritteninmost1anguages.Per1isacommonchoicebecauseitisdesignedfortextmanipu1ationandisinterpreted,soitcanbeinsta11edonanyserverregard1essofprocessororoperatingsystem.Manypowerfu1Websitestodayarebui1tstrict1yonCGI,andyoucaninfactdonear1yanythingwithit.However,Websitesbui1tonCGIprogramscanrapid1ybecomeover1ycomp1icatedtomaintain,andthereisa1sotheprob1emofresponsetime.TheresponseofaCGIprogramdependsonhowmuchdatamustbesent,aswe11asthe1oadonboththeserverandtheInternet.(Ontopofthis,startingaCGIprogramtendstobes1ow.)Theinitia1designersoftheWebdidnotforeseehowrapid1ythisbandwidthwou1dbeexhaustedforthekindsofapp1icationspeop1edeve1oped.Forexamp1e,anysortofdynamicgraphingisnear1yimpossib1etoperformwithconsistencybecauseaGIFfi1emustbecreatedandmovedfromtheservertothec1ientforeachversionofthegraph.Andyou,venodoubthaddirectexperiencewithsomethingassimp1easva1idatingthedataonaninputform.Youpressthesubmitbuttononapage;thedataisshippedbacktotheserver;theserverstartsaCGIprogramthatdiscoversanerror,formatsanHTM1pageinformingyouoftheerror,andthensendsthepagebacktoyou;youmustthenbackupapageandtryagain.Noton1yisthiss1ow,it,sine1egant.Theso1utionisc1ient-sideprogramming.MostmachinesthatrunWebbrowsersarepowerfu1enginescapab1eofdoingvastwork,andwiththeorigina1staticHTM1approachtheyaresittingthere,justid1ywaitingfortheservertodishupthenextpage.C1ient-sideprogrammingmeansthattheWebbrowserisharnessedtodowhateverworkitcan,andtheresu1tfortheuserisamuchspeedierandmoreinteractiveexperienceatyourWebsite.Theprob1emwithdiscussionsofc1ient-sideprogrammingisthattheyaren,tverydifferentfromdiscussionsofprogrammingingenera1.Theparametersarea1mostthesame,butthep1atformisdifferent:aWebbrowseris1ikea1imitedoperatingsystem.Intheend,youmuststi11program,andthisaccountsforthedizzyingarrayofprob1emsandso1utionsproducedbyc1ient-sideprogramming.Therestofthissectionprovidesanoverviewoftheissuesandapproachesinc1ient-sideprogramming.2.P1ug-insOneofthemostsignificantstepsforwardinc1ient-sideprogrammingisthedeve1opmentofthep1ug-in.Thisisawayforaprogrammertoaddnewfunctiona1itytothebrowserbydown1oadingapieceofcodethatp1ugsitse1fintotheappropriatespotinthebrowser.Itte11sthebrowsertfromnowonyoucanperformthisnewactivity/'(Youneedtodown1oadthep1ug-inon1yonce.)Somefastandpowerfu1behaviorisaddedtobrowsersviap1ug-ins,butwritingap1ug-inisnotatrivia1task,andisn,tsomethingyou,dwanttodoaspartoftheprocessofbui1dingaparticu1arsite.Theva1ueofthep1ug-inforc1ient-sideprogrammingisthatita11owsanexpertprogrammertodeve1opanew1anguageandaddthat1anguagetoabrowserwithoutthepermissionofthebrowsermanufacturer.Thus,p1ug-insprovideatbackdoof,thata11owsthecreationofnewc1ient-sideprogramming1anguages(a1thoughnota111anguagesareimp1ementedasp1ug-ins).3.Scripting1anguagesP1ug-insresu1tedinanexp1osionofscripting1anguages.Withascripting1anguageyouembedthesourcecodeforyourc1ient-sideprogramdirect1yintotheHTM1page,andthep1ug-inthatinterpretsthat1anguageisautomatica11yactivatedwhi1etheHTM1pageisbeingdisp1ayed.Scripting1anguagestendtobereasonab1yeasytounderstandand,becausetheyaresimp1ytextthatispartofanHTM1page,they1oadveryquick1yaspartofthesing1eserverhitrequiredtoprocurethatpage.Thetrade-offisthatyourcodeisexposedforeveryonetosee(andstea1).Genera11y,however,youaren,tdoingamazing1ysophisticatedthingswithscripting1anguagessothisisnottoomuchofahardship.Thispointsoutthatthescripting1anguagesusedinsideWebbrowsersarerea11yintendedtoso1vespecifictypesofprob1ems,primari1ythecreationofricherandmoreinteractivegraphica1userinterfaces(GUIs).However,ascripting1anguagemightso1ve80percentoftheprob1emsencounteredinc1ient-sideprogramming.Yourprob1emsmightverywe11fitcomp1ete1ywithinthat80percent,andsincescripting1anguagescana11oweasierandfasterdeve1opment,youshou1dprobab1yconsiderascripting1