![JAVA外文文獻(xiàn)翻譯11_第1頁(yè)](http://file4.renrendoc.com/view14/M02/0B/03/wKhkGWbEG_SAQyzyAAJ3eQU7OHY150.jpg)
![JAVA外文文獻(xiàn)翻譯11_第2頁(yè)](http://file4.renrendoc.com/view14/M02/0B/03/wKhkGWbEG_SAQyzyAAJ3eQU7OHY1502.jpg)
![JAVA外文文獻(xiàn)翻譯11_第3頁(yè)](http://file4.renrendoc.com/view14/M02/0B/03/wKhkGWbEG_SAQyzyAAJ3eQU7OHY1503.jpg)
![JAVA外文文獻(xiàn)翻譯11_第4頁(yè)](http://file4.renrendoc.com/view14/M02/0B/03/wKhkGWbEG_SAQyzyAAJ3eQU7OHY1504.jpg)
![JAVA外文文獻(xiàn)翻譯11_第5頁(yè)](http://file4.renrendoc.com/view14/M02/0B/03/wKhkGWbEG_SAQyzyAAJ3eQU7OHY1505.jpg)
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
第頁(yè)JavaandtheInternetIfJavais,infact,yetanothercomputerprogramminglanguage,youmayquestionwhyitissoimportantandwhyitisbeingpromotedasarevolutionarystepincomputerprogramming.Theanswerisn’timmediatelyobviousifyou’recomingfromatraditionalprogrammingperspective.AlthoughJavaisveryusefulforsolvingtraditionalstand-aloneprogrammingproblems,itisalsoimportantbecauseitwillsolveprogrammingproblemsontheWorldWideWeb.Client-sideprogrammingTheWeb’sinitialserver-browserdesignprovidedforinteractivecontent,buttheinteractivitywascompletelyprovidedbytheserver.Theserverproducedstaticpagesfortheclientbrowser,whichwouldsimplyinterpretanddisplaythem.BasicHTMLcontainssimplemechanismsfordatagathering:text-entryboxes,checkboxes,radioboxes,listsanddrop-downlists,aswellasabuttonthatcanonlybeprogrammedtoresetthedataontheformor“submit”thedataontheformbacktotheserver.ThissubmissionpassesthroughtheCommonGatewayInterface(CGI)providedonallWebservers.ThetextwithinthesubmissiontellsCGIwhattodowithit.Themostcommonactionistorunaprogramlocatedontheserverinadirectorythat’stypicallycalled“cgi-bin.”(IfyouwatchtheaddresswindowatthetopofyourbrowserwhenyoupushabuttononaWebpage,youcansometimessee“cgi-bin”withinallthegobbledygookthere.)Theseprogramscanbewritteninmostlanguages.Perlisacommonchoicebecauseitisdesignedfortextmanipulationandisinterpreted,soitcanbeinstalledonanyserverregardlessofprocessororoperatingsystem.ManypowerfulWebsitestodayarebuiltstrictlyonCGI,andyoucaninfactdonearlyanythingwithit.However,WebsitesbuiltonCGIprogramscanrapidlybecomeoverlycomplicatedtomaintain,andthereisalsotheproblemofresponsetime.TheresponseofaCGIprogramdependsonhowmuchdatamustbesent,aswellastheloadonboththeserverandtheInternet.(Ontopofthis,startingaCGIprogramtendstobeslow.)TheinitialdesignersoftheWebdidnotforeseehowrapidlythisbandwidthwouldbeexhaustedforthekindsofapplicationspeopledeveloped.Forexample,anysortofdynamicgraphingisnearlyimpossibletoperformwithconsistencybecauseaGIFbecreatedandmovedfromtheservertotheclientforeachversionofthegraph.Andyou’venodoubthaddirectexperiencewithsomethingassimpleasvalidatingthedataonaninputform.Youpressthesubmitbuttononapage;thedataisshippedbacktotheserver;theserverstartsaCGIprogramthatdiscoversanerror,formatsanHTMLpageinformingyouoftheerror,andthensendsthepagebacktoyou;youmustthenbackupapageandtryagain.Notonlyisthisslow,it’sinelegant.Thesolutionisclient-sideprogramming.MostmachinesthatrunWebbrowsersarepowerfulenginescapableofdoingvastwork,andwiththeoriginalstaticHTMLapproachtheyaresittingthere,justidlywaitingfortheservertodishupthenextpage.Client-sideprogrammingmeansthattheWebbrowserisharnessedtodowhateverworkitcan,andtheresultfortheuserisamuchspeedierandmoreinteractiveexperienceatyourWebsite.Theproblemwithdiscussionsofclient-sideprogrammingisthattheyaren’tverydifferentfromdiscussionsofprogrammingingeneral.Theparametersarealmostthesame,buttheplatformisdifferent:aWebbrowserislikealimitedoperatingsystem.Intheend,youmuststillprogram,andthisaccountsforthedizzyingarrayofproblemsandsolutionsproducedbyclient-sideprogramming.Therestofthissectionprovidesanoverviewoftheissuesandapproachesinclient-sideprogramming.2.Plug-insOneofthemostsignificantstepsforwardinclient-sideprogrammingisthedevelopmentoftheplug-in.Thisisawayforaprogrammertoaddnewfunctionalitytothebrowserbydownloadingapieceofcodethatplugsitselfintotheappropriatespotinthebrowser.Ittellsthebrowser“fromnowonyoucanperformthisnewactivity.”(Youneedtodownloadtheplug-inonlyonce.)Somefastandpowerfulbehaviorisaddedtobrowsersviaplug-ins,butwritingaplug-inisnotatrivialtask,andisn’tsomethingyou’dwanttodoaspartoftheprocessofbuildingaparticularsite.Thevalueoftheplug-inforclient-sideprogrammingisthatitallowsanexpertprogrammertodevelopanewlanguageandaddthatlanguagetoabrowserwithoutthepermissionofthebrowsermanufacturer.Thus,plug-insprovidea“backdoor”thatallowsthecreationofnewclient-sideprogramminglanguages(althoughnotalllanguagesareimplementedasplug-ins).3.ScriptinglanguagesPlug-insresultedinanexplosionofscriptinglanguages.Withascriptinglanguageyouembedthesourcecodeforyourclient-sideprogramdirectlyintotheHTMLpage,andtheplug-inthatinterpretsthatlanguageisautomaticallyactivatedwhiletheHTMLpageisbeingdisplayed.Scriptinglanguagestendtobereasonablyeasytounderstandand,becausetheyaresimplytextthatispartofanHTMLpage,theyloadveryquicklyaspartofthesingleserverhitrequiredtoprocurethatpage.Thetrade-offisthatyourcodeisexposedforeveryonetosee(andsteal).Generally,however,youaren’tdoingamazinglysophisticatedthingswithscriptinglanguagessothisisnottoomuchofahardship.ThispointsoutthatthescriptinglanguagesusedinsideWebbrowsersarereallyintendedtosolvespecifictypesofproblems,primarilythecreationofricherandmoreinteractivegraphicaluserinterfaces(GUIs).However,ascriptinglanguagemightsolve80percentoftheproblemsencounteredinclient-sideprogramming.Yourproblemsmightverywellfitcompletelywithinthat80percent,andsincescriptinglanguagescanalloweasierandfasterdevelopment,youshouldprobablyconsiderascriptinglanguagebeforelookingatamoreinvolvedsolutionsuchasJavaorActiveXprogramming.ThemostcommonlydiscussedbrowserscriptinglanguagesareJavaScript(whichhasnothingtodowithJava;it’snamedthatwayjusttograbsomeofJava’smarketingmomentum),VBScript(whichlookslikeVisualBasic),andTcl/Tk,whichcomesfromthepopularcross-platformGUI-buildinglanguage.Thereareothersoutthere,andnodoubtmoreindevelopment.JavaScriptisprobablythemostcommonlysupported.ItcomesbuiltintobothNetscapeNavigatorandtheMicrosoftInternetExplorer(IE).Inaddition,thereareprobablymoreJavaScriptbooksavailablethantherearefortheotherbrowserlanguages,andsometoolsautomaticallycreatepagesusingJavaScript.However,ifyou’realreadyfluentinVisualBasicorTcl/Tk,you’llbemoreproductiveusingthosescriptinglanguagesratherthanlearninganewone.(You’llhaveyourhandsfulldealingwiththeWebissuesalready.)4.JavaIfascriptinglanguagecansolve80percentoftheclient-sideprogrammingproblems,whatabouttheother20percent—the“reallyhardstuff?”ThemostpopularsolutiontodayisJava.Notonlyisitapowerfulprogramminglanguagebuilttobesecure,cross-platform,andinternational,butJavaisbeingcontinuallyextendedtoprovidelanguagefeaturesandlibrariesthatelegantlyhandleproblemsthataredifficultintraditionalprogramminglanguages,suchasmultithreading,databaseaccess,networkprogramming,anddistributedcomputing.Javaallowsclient-sideprogrammingviatheapplet.Anappletisamini-programthatwillrunonlyunderaWebbrowser.TheappletisdownloadedautomaticallyaspartofaWebpage(justas,forexample,agraphicisautomaticallydownloaded).Whentheappletisactivateditexecutesaprogram.Thisispartofitsbeauty—itprovidesyouwithawaytoautomaticallydistributetheclientsoftwarefromtheserveratthetimetheuserneedstheclientsoftware,andnosooner.Theusergetsthelatestversionoftheclientsoftwarewithoutfailandwithoutdifficultreinstallation.BecauseofthewayJavaisdesigned,theprogrammerneedstocreateonlyasingleprogram,andthatprogramautomaticallyworkswithallcomputersthathavebrowserswithbuilt-inJavainterpreters.(Thissafelyincludesthevastmajorityofmachines.)SinceJavaisafull-fledgedprogramminglanguage,youcandoasmuchworkaspossibleontheclientbeforeandaftermakingrequestsoftheserver.Forexample,youwon’tneedtosendarequestformacrosstheInternettodiscoverthatyou’vegottenadateorsomeotherparameterwrong,andyourclientcomputercanquicklydotheworkofplottingdatainsteadofwaitingfortheservertomakeaplotandshipagraphicimagebacktoyou.Notonlydoyougettheimmediatewinofspeedandresponsiveness,butthegeneralnetworktrafficandloadonserverscanbereduced,preventingtheentireInternetfromslowingdown.OneadvantageaJavaapplethasoverascriptedprogramisthatit’sincompiledform,sothesourcecodeisn’tavailabletotheclient.Ontheotherhand,aJavaappletcanbedecompiledwithouttoomuchtrouble,buthidingyourcodeisoftennotanimportantissue.Twootherfactorscanbeimportant.Asyouwillseelaterinthisbook,acompiledJavaappletcancomprisemanymodulesandtakemultipleserver“hits”(accesses)todownload.(InJava1.1andhigherthisisminimizedbyJavaarchives,calledJARfiles,thatallowalltherequiredmodulestobepackagedtogetherandcompressedforasingledownload.)AscriptedprogramwilljustbeintegratedintotheWebpageaspartofitstext(andwillgenerallybesmallerandreduceserverhits).ThiscouldbeimportanttotheresponsivenessofyourWebsite.Anotherfactoristheall-importantlearningcurve.Regardlessofwhatyou’veheard,Javaisnotatriviallanguagetolearn.Ifyou’reaVisualBasicprogrammer,movingtoVBScriptwillbeyourfastestsolution,andsinceitwillprobablysolvemosttypicalclient/serverproblemsyoumightbehardpressedtojustifylearningJava.Ifyou’reexperiencedwithascriptinglanguageyouwillcertainlybenefitfromlookingatJavaScriptorVBScriptbeforecommittingtoJava,sincetheymightfityourneedshandilyandyou’llbemoreproductivesooner.torunitsappletswithi5.ActiveXTosomedegree,thecompetitortoJavaisMicrosoft’sActiveX,althoughittakesacompletelydifferentapproach.ActiveXwasoriginallyaWindows-onlysolution,althoughitisnowbeingdevelopedviaanindependentconsortiumtobecomecross-platform.Effectively,ActiveXsays“ifyourprogramconnectstoitsenvironmentjustso,itcanbedroppedintoaWebpageandrununderabrowserthatsupportsActiveX.”(IEdirectlysupportsActiveXandNetscapedoessousingaplug-in.)Thus,ActiveXdoesnotconstrainyoutoaparticularlanguage.If,forexample,you’realreadyanexperiencedWindowsprogrammerusingalanguagesuchasC++,VisualBasic,orBorland’sDelphi,youcancreateActiveXcomponentswithalmostnochangestoyourprogrammingknowledge.ActiveXalsoprovidesapathfortheuseoflegacycodeinyourWebpages.6.SecurityAutomaticallydownloadingandrunningprogramsacrosstheInternetcansoundlikeavirus-builder’sdream.ActiveXespeciallybringsupthethornyissueofsecurityinclient-sideprogramming.IfyouclickonaWebsite,youmightautomaticallydownloadanynumberofthingsalongwiththeHTMLpage:GIFfiles,scriptcode,compiledJavacode,andActiveXcomponents.Someofthesearebenign;GIFfilescan’tdoanyharm,andscriptinglanguagesaregenerallylimitedinwhattheycando.Javawasalsodesignedtorunitsappletswithina“sandbox”ofsafety,whichpreventsitfromwritingtodiskoraccessingmemoryoutsidethesandbox.ActiveXisattheoppositeendofthespectrum.ProgrammingwithActiveXislikeprogrammingWindows—youcandoanythingyouwant.SoifyouclickonapagethatdownloadsanActiveXcomponent,thatcomponentmightcausedamagetothefilesonyourdisk.Ofcourse,programsthatyouloadontoyourcomputerthatarenotrestrictedtorunninginsideaWebbrowsercandothesamething.VirusesdownloadedfromBulletin-BoardSystems(BBSs)havelongbeenaproblem,butthespeedoftheInternetamplifiesthedifficulty.Thesolutionseemstobe“digitalsignatures,”wherebycodeisverifiedtoshowwhotheauthoris.Thisisbasedontheideathatavirusworksbecauseitscreatorcanbeanonymous,soifyouremovetheanonymityindividualswillbeforcedtoberesponsiblefortheiractions.Thisseemslikeagoodplanbecauseitallowsprogramstobemuchmorefunctional,andIsuspectitwilleliminatemaliciousmischief.If,however,aprogramhasanunintentionaldestructivebugitwillstillcauseproblems.TheJavaapproachistopreventtheseproblemsfromoccurring,viathesandbox.TheJavainterpreterthatlivesonyourlocalWebbrowserexaminestheappletforanyuntowardinstructionsastheappletisbeingloaded.Inparticular,theappletcannotwritefilestodiskorerasefiles(oneofthemainstaysofviruses).Appletsaregenerallyconsideredtobesafe,andsincethisisessentialforreliableclient/serversystems,anybugsintheJavalanguagethatallowvirusesarerapidlyrepaired.(It’sworthnotingthatthebrowsersoftwareactuallyenforcesthesesecurityrestrictions,andsomebrowsersallowyoutoselectdifferentsecuritylevelstoprovidevaryingdegreesofaccesstoyoursystem.)Youmightbeskepticalofthisratherdraconianrestrictionagainstwritingfilestoyourlocaldisk.Forexample,youmaywanttobuildalocaldatabaseorsavedataforlateruseoffline.Theinitialvisionseemedtobethateventuallyeveryonewouldgetonlinetodoanythingimportant,butthatwassoonseentobeimpractical(althoughlow-cost“Internetappliances”mightsomedaysatisfytheneedsofasignificantsegmentofusers).Thesolutionisthe“signedapplet”thatusespublic-keyencryptiontoverifythatanappletdoesindeedcomefromwhereitclaimsitdoes.Asignedappletcanstilltrashyourdisk,butthetheoryisthatsinceyoucannowholdtheappletcreatoraccountabletheywon’tdoviciousthings.Javaprovidesaframeworkfordigitalsignaturessothatyouwilleventuallybeabletoallowanapplettostepoutsidethesandboxifnecessary.Digitalsignatureshavemissedanimportantissue,whichisthespeedthatpeoplemovearoundontheInternet.Ifyoudownloadabuggyprogramanditdoessomethinguntoward,howlongwillitbebeforeyoudiscoverthedamage?Itcouldbedaysorevenweeks.Bythen,howwillyoutrackdowntheprogramthat’sdoneit?Andwhatgoodwillitdoyouatthatpoint?7.Internetvs.intranetTheWebisthemostgeneralsolutiontotheclient/serverproblem,soitmakessensethatyoucanusethesametechnologytosolveasubsetoftheproblem,inparticulartheclassicclient/serverproblemwithinacompany.Withtraditionalclient/serverapproachesyouhavetheproblemofmultipletypesofclientcomputers,aswellasthedifficultyofinstallingnewclientsoftware,bothofwhicharehandilysolvedwithWebbrowsersandclient-sideprogramming.WhenWebtechnologyisusedforaninformationnetworkthatisrestrictedtoaparticularcompany,itisreferredtoasanintranet.IntranetsprovidemuchgreatersecuritythantheInternet,sinceyoucanphysicallycontrolaccesstotheserverswithinyourcompany.Intermsoftraining,itseemsthatoncepeopleunderstandthegeneralconceptofabrowserit’smucheasierforthemtodealwithdifferencesinthewaypagesandappletslook,sothelearningcurvefornewkindsofsystemsseemstobereduced.Thesecurityproblembringsustooneofthedivisionsthatseemstobeautomaticallyformingintheworldofclient-sideprogramming.IfyourprogramisrunningontheInternet,youdon’tknowwhatplatformitwillbeworkingunder,andyouwanttobeextracarefulthatyoudon’tdisseminatebuggycode.Youneedsomethingcross-platformandsecure,likeascriptinglanguageorJava.Ifyou’rerunningonanintranet,youmighthaveadifferentsetofconstraints.It’snotuncommonthatyourmachinescouldallbeIntel/Windowsplatforms.Onanintranet,you’reresponsibleforthequalityofyourowncodeandcanrepairbugswhenthey’rediscovered.Inaddition,youmightalreadyhaveabodyoflegacycodethatyou’vebeenusinginamoretraditionalclient/serverapproach,wherebyyoumustphysicallyinstallclientprogramseverytimeyoudoanupgrade.Thetimewastedininstallingupgradesisthemostcompellingreasontomovetobrowsers,becauseupgradesareinvisibleandautomatic.Ifyouareinvolvedinsuchanintranet,themostsensibleapproachtotakeistheshortestpaththatallowsyoutouseyourexistingcodebase,ratherthantryingtorecodeyourprogramsinanewlanguage.Whenfacedwiththisbewilderingarrayofsolutionstotheclient-sideprogrammingproblem,thebestplanofattackisacost-benefitanalysis.Considertheconstraintsofyourproblemandwhatwouldbetheshortestpathtoyoursolution.Sinceclient-sideprogrammingisstillprogramming,it’salwaysagoodideatotakethefastestdevelopmentapproachforyourparticularsituation.Thisisanaggressivestancetoprepareforinevitableencounterswiththeproblemsofprogramdevelopment.8.Server-sideprogrammingThiswholediscussionhasignoredtheissueofserver-sideprogramming.Whathappenswhenyoumakearequestofaserver?Mostofthetimetherequestissimply“sendmethisfile.”Yourbrowsertheninterpretsthesomeappropriatefashion:asanHTMLpage,agraphicimage,aJavaapplet,ascriptprogram,etc.Amorecomplicatedrequesttoaservergenerallyinvolvesadatabasetransaction.Acommonscenarioinvolvesarequestforacomplexdatabasesearch,whichtheserverthenformatsintoanHTMLpageandsendstoyouastheresult.(Ofcourse,iftheclienthasmoreintelligenceviaJavaorascriptinglanguage,therawdatacanbesentandformattedattheclientend,whichwillbefasterandlessloadontheserver.)Oryoumightwanttoregisteryournameinadatabasewhenyoujoinagrouporplaceanorder,whichwillinvolvechangestothatdatabase.Thesedatabaserequestsmustbeprocessedviasomecodeontheserverside,whichisgenerallyreferredtoasserver-sideprogramming.Traditionally,server-sideprogramminghasbeenperformedusingPerlandCGIscripts,butmoresophisticatedsystemshavebeenappearing.TheseincludeJava-basedWebserversthatallowyoutoperformallyourserver-sideprogramminginJavabywritingwhatarecalledservlets.Servletsandtheiroffspring,JSPs,aretwoofthemostcompellingreasonsthatcompanieswhodevelopWebsitesaremovingtoJava,especiallybecausetheyeliminatetheproblemsofdealingwithdifferentlyabledbrowsers.9.separatearena:applicationsMuchofthebrouhahaoverJavahasbeenoverapplets.Javaisactuallyageneral-purposeprogramminglanguagethatcansolveanytypeofproblem—atleastintheory.Andaspointedoutpreviously,theremightbemoreeffectivewaystosolvemostclient/serverproblems.Whenyoumoveoutoftheappletarena(andsimultaneouslyreleasetherestrictions,suchastheoneagainstwritingtodisk)youentertheworldofgeneral-purposeapplicationsthatrunstandalone,withoutaWebbrowser,justlikeanyordinaryprogramdoes.Here,Java’sstrengthisnotonlyinitsportability,butalsoitsprogrammability.Asyou’llseethroughoutthisbook,Javahasmanyfeaturesthatallowyoutocreaterobustprogramsinashorterperiodthanwithpreviousprogramminglanguages.Beawarethatthisisamixedblessing.Youpayfortheimprovementsthroughslowerexecutionspeed(althoughthereissignificantworkgoingoninthisarea—JDK1.3,inparticular,introducestheso-called“hotspot”performanceimprovements).Likeanylanguage,Javahasbuilt-inlimitationsthatmightmakeitinappropriatetosolvecertaintypesofprogrammingproblems.Javaisarapidlyevolvinglanguage,however,andaseachnewreleasecomesoutitbecomesmoreandmoreattractiveforsolvinglargersetsofproblems.Java和因特網(wǎng)既然Java不過(guò)另一種類型的程序設(shè)計(jì)語(yǔ)言,大家可能會(huì)奇怪它為什么值得如此重視,為什么還有這么多的人認(rèn)為它是計(jì)算機(jī)程序設(shè)計(jì)的一個(gè)里程碑呢?如果您來(lái)自一個(gè)傳統(tǒng)的程序設(shè)計(jì)背景,那么答案在剛開始的時(shí)候并不是很明顯。Java除了可解決傳統(tǒng)的程序設(shè)計(jì)問(wèn)題以外,還能解決WorldWideWeb(萬(wàn)維網(wǎng))上的編程問(wèn)題。1.客戶端編程Web最初采用的“服務(wù)器-瀏覽器”方案可提供交互式內(nèi)容,但這種交互能力完全由服務(wù)器提供,為服務(wù)器和因特網(wǎng)帶來(lái)了不小的負(fù)擔(dān)。服務(wù)器一般為客戶瀏覽器產(chǎn)生靜態(tài)網(wǎng)頁(yè),由后者簡(jiǎn)單地解釋并顯示出來(lái)?;綡TML語(yǔ)言提供了簡(jiǎn)單的數(shù)據(jù)收集機(jī)制:文字輸入框、復(fù)選框、單選鈕、列表以及下拉列表等,另外還有一個(gè)按鈕,只能由程序規(guī)定重新設(shè)置表單中的數(shù)據(jù),以便回傳給服務(wù)器。用戶提交的信息通過(guò)所有Web服務(wù)器均能支持的“通用網(wǎng)關(guān)接口”(CGI)回傳到服務(wù)器。包含在提交數(shù)據(jù)中的文字指示CGI該如何操作。最常見的行動(dòng)是運(yùn)行位于服務(wù)器的一個(gè)程序。那個(gè)程序一般保存在一個(gè)名為“cgi-bin”的目錄中(按下Web頁(yè)內(nèi)的一個(gè)按鈕時(shí),請(qǐng)注意一下瀏覽器頂部的地址窗,經(jīng)常都能發(fā)現(xiàn)“cgi-bin”的字樣)。大多數(shù)語(yǔ)言都可用來(lái)編制這些程序,但其中最常見的是Perl。這是由于Perl是專為文字的處理及解釋而設(shè)計(jì)的,所以能在任何服務(wù)器上安裝和使用,無(wú)論采用的處理器或操作系統(tǒng)是什么。2.插件朝客戶端編程邁進(jìn)的時(shí)候,最重要的一個(gè)問(wèn)題就是插件的設(shè)計(jì)。利用插件,程序員可以方便地為瀏覽器添加新功能,用戶只需下載一些代碼,把它們“插入”瀏覽器的適當(dāng)位置即可。這些代碼的作用是告訴瀏覽器“從現(xiàn)在開始,你可以進(jìn)行這些新活動(dòng)了”(僅需下載這些插入一次)。有些快速和功能強(qiáng)大的行為是通過(guò)插件添加到瀏覽器的。但插件的編寫并不是一件簡(jiǎn)單的任務(wù)。在我們構(gòu)建一個(gè)特定的站點(diǎn)時(shí),可能并不希望涉及這方面的工作。對(duì)客戶端程序設(shè)計(jì)來(lái)說(shuō),插件的價(jià)值在于它允許專業(yè)程序員設(shè)計(jì)出一種新的語(yǔ)言,并將那種語(yǔ)言添加到瀏覽器,同時(shí)不必經(jīng)過(guò)瀏覽器原創(chuàng)者的許可。由此可以看出,插件實(shí)際是瀏覽器的一個(gè)“后門”,允許創(chuàng)建新的客戶端程序設(shè)計(jì)語(yǔ)言(盡管并非所有語(yǔ)言都是作為插件實(shí)現(xiàn)的)。3.腳本編制語(yǔ)言插件造成了腳本編制語(yǔ)言的爆炸性增長(zhǎng)。通過(guò)這種腳本語(yǔ)言,可將用于自己客戶端程序的源碼直接插入HTML頁(yè),而對(duì)那種語(yǔ)言進(jìn)行解釋的插件會(huì)在HTML頁(yè)顯示的時(shí)候自動(dòng)激活。腳本語(yǔ)言一般都傾向于盡量簡(jiǎn)化,易于理解。而且由于它們是從屬于HTML頁(yè)的一些簡(jiǎn)單正文,所以只需向服務(wù)器發(fā)出對(duì)那個(gè)頁(yè)的一次請(qǐng)求,即可非??斓剌d入。缺點(diǎn)是我們的代碼全部暴露在人們面前。另一方面,由于通常不用腳本編制語(yǔ)言做過(guò)分復(fù)雜的事情,所以這個(gè)問(wèn)題暫且可以放在一邊。腳本語(yǔ)言真正面向的是特定類型問(wèn)題的解決,其中主要涉及如何創(chuàng)建更豐富、更具有互動(dòng)能力的圖形用戶界面(GUI)。然而,腳本語(yǔ)言也許能解決客戶端編程中80%的問(wèn)題。你碰到的問(wèn)題可能完全就在那80%里面。而且由于腳本編制語(yǔ)言的宗旨是盡可能地簡(jiǎn)化及快速,所以在考慮其他更復(fù)雜的方案之前(如Java及ActiveX),首先應(yīng)想一下腳本語(yǔ)言是否可行。目前討論得最多的腳本編制語(yǔ)言包括JavaScript(它及Java沒(méi)有任何關(guān)系;之所以叫那個(gè)名字,完全是一種市場(chǎng)策略)、VBScript(同VisualBasic很相似)以及Tcl/Tk(來(lái)源于流行的跨平臺(tái)GUI構(gòu)造語(yǔ)言)。當(dāng)然還有其他許多語(yǔ)言,也有許多正在開發(fā)中。JavaScript也許是日常用的,它得到的支持也最全面。無(wú)論NetscapeNavigator,MicrosoftInternetExplorer,還是Opera,目前都提供了對(duì)JavaScript的支持。除此以外,市面上講述JavaScript的書籍也要比講述其他語(yǔ)言的書多得多。有些工具還能利用JavaScript自動(dòng)產(chǎn)生網(wǎng)頁(yè)。當(dāng)然,如果你已經(jīng)有VisualBasic或者Tcl/Tk的深厚功底,當(dāng)然用它們要簡(jiǎn)單得多,起碼可以避免學(xué)習(xí)新語(yǔ)言的煩惱(解決Web方面的問(wèn)題就已經(jīng)夠讓人頭痛了)。4.Java如果說(shuō)一種腳本編制語(yǔ)言能解決80%的客戶端程序設(shè)計(jì)問(wèn)題,那么剩下的20%又該怎么辦呢?它們屬于一些高難度的問(wèn)題嗎?目前最流行的方案就是Java。它不僅是一種功能強(qiáng)大、高度安全、可以跨平臺(tái)使用以及國(guó)際通用的程序設(shè)計(jì)語(yǔ)言,也是一種具有旺盛生命力的語(yǔ)言。對(duì)Java的擴(kuò)展是不斷進(jìn)行的,提供的語(yǔ)言特性和庫(kù)能夠很好地解決傳統(tǒng)語(yǔ)言不能解決的問(wèn)題,比如多線程操作、數(shù)據(jù)庫(kù)訪問(wèn)、連網(wǎng)程序設(shè)計(jì)以及分布式計(jì)算等等。Java通過(guò)“程序片”(Applet)巧妙地解決了客戶端編程的問(wèn)題。程序片(或“小應(yīng)用程序”)是一種非常小的程序,只能在Web瀏覽器中運(yùn)行。作為Web頁(yè)的一部分,程序片代碼會(huì)自動(dòng)下載回來(lái)(這和網(wǎng)頁(yè)中的圖片差不多)。激活程序片后,它會(huì)執(zhí)行一個(gè)程序。程序片的一個(gè)優(yōu)點(diǎn)體現(xiàn)在:通過(guò)程序片,一旦用戶需要客戶軟件,軟件就可從服務(wù)器自動(dòng)下載回來(lái)。它們能自動(dòng)取得客戶軟件的最新版本,不會(huì)出錯(cuò),也沒(méi)有重新安裝的麻煩。由于Java的設(shè)計(jì)原理,程序員只需要?jiǎng)?chuàng)建程序的一個(gè)版本,那個(gè)程序能在幾乎所有計(jì)算機(jī)以及安裝了Java解釋器的瀏覽器中運(yùn)行。由于Java是一種全功能的編程語(yǔ)言,所以在向服務(wù)器發(fā)出一個(gè)請(qǐng)求之前,我們能先在客戶端做完盡可能多的工作。例如,再也不必通過(guò)因特網(wǎng)傳送一個(gè)請(qǐng)求表單,再由服務(wù)器確定其中是否存在一個(gè)拼寫或者其他參數(shù)錯(cuò)誤。大多數(shù)數(shù)據(jù)校驗(yàn)工作均可在客戶端完成,沒(méi)有必要坐在計(jì)算機(jī)前面焦急地等待服務(wù)器的響應(yīng)。這樣一來(lái),不僅速度和響應(yīng)的靈敏度得到了極大的提高,對(duì)網(wǎng)絡(luò)和服務(wù)器造成的負(fù)擔(dān)也可以明顯減輕,這對(duì)保障因特網(wǎng)的暢通是至關(guān)重要的。
及腳本程序相比,Java程序片的另一個(gè)優(yōu)點(diǎn)是它采用編譯好的形式,所以客戶端看不到源碼。當(dāng)然在另一方面,反編譯Java程序片也并不是件難事,而且代碼的隱藏一般并不是個(gè)重要的問(wèn)題。大家要注意另外兩個(gè)重要的問(wèn)題。正如本書以前會(huì)講到的那樣,編譯好的Java程序片可能包含了許多模塊,所以要多次“命中”(訪問(wèn))服務(wù)器以便下載(在Java1.1中,這個(gè)問(wèn)題得到了有效的改善——利用Java壓縮檔,即JAR文件——它允許設(shè)計(jì)者將所有必要的模塊都封裝到一起,供用戶統(tǒng)一下載)。在另一方面,腳本程序是作為Web頁(yè)正文的一部分集成到Web頁(yè)內(nèi)的。這種程序一般都非常小,可有效減少對(duì)服務(wù)器的點(diǎn)擊數(shù)。另一個(gè)因素是學(xué)習(xí)方面的問(wèn)題。不管你平時(shí)聽別人怎么說(shuō),Java都不是一種十分容易便可學(xué)會(huì)的語(yǔ)言。如果你以前是一名VisualBasic程序員,那么轉(zhuǎn)向VBScript會(huì)是一種最快捷的方案。由于VBScript可以解決大多數(shù)典型的客戶機(jī)/服務(wù)器問(wèn)題,所以一旦上手,就很難下定決心再去學(xué)習(xí)Java。如果對(duì)腳本編制語(yǔ)言比較熟,那么在轉(zhuǎn)向Java之前,建議先熟悉一下JavaScript或者VBScript,因?yàn)樗鼈兛赡芤呀?jīng)能夠滿足你的需要,不必經(jīng)歷學(xué)習(xí)Java的艱苦過(guò)程。5.ActiveX在某種程度上,Java的一個(gè)有力競(jìng)爭(zhēng)對(duì)手應(yīng)該是微軟的ActiveX,盡管它采用的是完全不同的一套實(shí)現(xiàn)機(jī)制。ActiveX最早是一種純Windows的方案。經(jīng)過(guò)一家獨(dú)立的專業(yè)協(xié)會(huì)的努力,ActiveX現(xiàn)在已具備了跨平臺(tái)使用的能力。實(shí)際上,ActiveX的意思是“假如你的程序同它的工作環(huán)境正常連接,它就能進(jìn)入Web頁(yè),并在支持ActiveX的瀏覽器中運(yùn)行”(IE固化了對(duì)ActiveX的支持,而Netscape需要一個(gè)插件)。所以,ActiveX并沒(méi)有限制我們使用一種特定的語(yǔ)言。比如,假設(shè)我們已經(jīng)是一名有經(jīng)驗(yàn)的Windows程序員,能熟練地使用像C++、VisualBasic或者BorlandDelphi那樣的語(yǔ)言,就能幾乎不加任何學(xué)習(xí)地創(chuàng)建出ActiveX組件。事實(shí)上,ActiveX是在我們的Web頁(yè)中使用“歷史遺留”代碼的最佳途徑。6.安全自動(dòng)下載和通過(guò)因特網(wǎng)運(yùn)行程序聽起來(lái)就像是一個(gè)病毒制造者的夢(mèng)想。在客戶端的編程中,ActiveX帶來(lái)了最讓人頭痛的安全問(wèn)題。點(diǎn)擊一個(gè)Web站點(diǎn)的時(shí)候,可能會(huì)隨同HTML網(wǎng)頁(yè)傳回任何數(shù)量的東西:GIF文件、腳本代碼、編譯好的Java代碼以及ActiveX組件。有些是無(wú)害的;GIF文件不會(huì)對(duì)我們?cè)斐扇魏挝:Γ_本編制語(yǔ)言通常在自己可做的事情上有著很大的限制。Java也設(shè)計(jì)成在一個(gè)安全“沙箱”里在它的程序片中運(yùn)行,這樣可防止操作位于沙箱以外的磁盤或者內(nèi)存區(qū)域。ActiveX是所有這些里面最讓人擔(dān)心的。用ActiveX編寫程序就像編制Windows應(yīng)用程序——可以做自己想做的任何事情。下載回一個(gè)ActiveX組件后,它完全可能對(duì)我們磁盤上的文件造成破壞。當(dāng)然,對(duì)那些下載回來(lái)并不限于在Web瀏覽器內(nèi)部運(yùn)行的程序,它們同樣也可能破壞我們的系
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年中國(guó)主備自動(dòng)切換C波段收發(fā)信機(jī)市場(chǎng)調(diào)查研究報(bào)告
- 2025年豆芽項(xiàng)目可行性研究報(bào)告
- 2025年肥料定氮儀項(xiàng)目可行性研究報(bào)告
- 2025年硅膠真空袋材料項(xiàng)目可行性研究報(bào)告
- 2025年毛混紡產(chǎn)品項(xiàng)目可行性研究報(bào)告
- 2025年無(wú)水碘化鈉項(xiàng)目可行性研究報(bào)告
- 2025至2031年中國(guó)多功能壓力校驗(yàn)儀行業(yè)投資前景及策略咨詢研究報(bào)告
- 2025年圓頭六角重型鏈條鎖項(xiàng)目可行性研究報(bào)告
- 2025年半不銹鋼母嬰一體床項(xiàng)目可行性研究報(bào)告
- 2025至2031年中國(guó)ARA油行業(yè)投資前景及策略咨詢研究報(bào)告
- 農(nóng)產(chǎn)品質(zhì)量安全控制課件
- 尿失禁健康講座(SUI)
- lovo操作手冊(cè)中文翻譯版-professorgong
- 南網(wǎng)5S管理、四步法、八步驟
- 管道工程污水管網(wǎng)監(jiān)理規(guī)劃(共44)
- 危貨運(yùn)輸車輛日常維護(hù)檢查及記錄表
- excel表格水池側(cè)壁及底板配筋計(jì)算程序(自動(dòng)版)
- 公司生產(chǎn)報(bào)廢單
- 乘法口訣表(到25乘25)
- 建設(shè)工程施工合同糾紛案件要點(diǎn)分析課件
- TPM“2”STEP培訓(xùn)方法和技巧(發(fā)生源困難源對(duì)策=兩源改善)
評(píng)論
0/150
提交評(píng)論