【良心出品】JAVA外文文献+翻译_第1页
【良心出品】JAVA外文文献+翻译_第2页
免费预览已结束,剩余15页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、燕山大学本科生毕业设计(翻译)1Java and the InternetIf Java is, in fact, yet another computer programming Ianguage, you may question why itis so important and why it is being promoted as a revolutionary step in computerprogramming. The answer isn t immediately obvious if youcoming from a traditional programming pe

2、rspective. Although Java is very useful for solvingtraditional stand-alone programming problems, it is also importa nt because it will solveprogram ming problems on the World Wide Web.1. Client-side programmingThe Web s itial server-browser desig n provided for in teractive content, but the interact

3、ivity was completely provided by the server. The server produced static pages for theclient browser, which would simply interpret and display them. Basic HTML contains simplemechanismsfor data gathering: text-entry boxes, check boxes, radio boxes, lists anddrop-dow n lists, as well as a butt on that

4、 can only be programmed to reset the data on theform or“ submiton the form back to the server. This submissi on passesthrough the Com mon Gateway Interface (CGI) provided on all Web servers. The text within the submissi on tells CGI what todo with it. The most com mon actio n is to run a program loc

5、ated on the server in a directorythat s typ-caily calledyou watch the addresswindow at the top of your browser when you push a butt on on a Webpage, you can sometimes see “ cgb in ” with in all the gobbledygook there.) Theseprograms can be writte n in most la nguages. Perl is a com mon choice becaus

6、e it is designed for text mani pulati on and is in terpreted, so it can be in stalled on any server regardlessof processor or operat ing system.Many powerful Web sites today are built strictly on CGI, and you can in fact do nearlyanything with it. However, Web sites built on CGI programs can rapidly

7、 become overlycomplicated to main tai n, and there is also the problem of resp onse time. The resp onse ofa CGI program depe nds on how much data must be sent, as well as the load on both the燕山大学本科生毕业设计(翻译)2server and the Intern et. (On top of this, start ing a CGI program tends to be slow.) The in

8、itialdesig ners of the Web did not foresee how rapidly this bandwidth would be exhausted forthe kinds of applicati ons people developed. For example, any sort of dyn amic graph ing isnearly impossible to perform with consistency because a GIF file must be created andmoved from the server to the clie

9、 nt for each versi on of the graph. And you veno doubt haddirect experienee with something as simple as validat ing the data on an in put form. Youpress the submit butt on on a page; the data is shipped back to the server; the server startsa CGI program that discovers an error, formats an HTML page

10、informing you of the error,and then sends the page back to you; you must the n back up a page and try aga in. Notonly is this slow, it s inelegant.The solution is client-side programming. Most machines that run Web browsers arepowerful engines capable of doing vast work, and with the origi nal stati

11、c HTML approachthey are sitting there, just idly waiting for the server to dish up the n ext page. Clie nt-sideprogram ming means that the Web browser is harnessedto do whatever work it can, and theresult for the user is a much speedier and more in teractive experie nee at your Web site.The problem

12、with discussions of client-side prog ramming is that they aren t very different from discussi ons of program ming in gen eral. The parameters are almost the same, butthe platform is different: a Web browser is like a limited operati ng system .In the end, youmust still program, and this acco unts fo

13、r the dizzy ing array of problems and soluti onsproduced by clie nt-side program ming. The rest of this sect ion provides an overview of theissues and approachesi n clie nt-side program ming.2. Plug-insOne of the most significant steps forward in client-side programming is the developmentof the plug

14、-in. This is a way for a programmer to add new functionality to the browser bydownloading a piece of code that plugs itself into the appropriate spot in the browser. It tellsthe browser“ from nowon yperform this new activity.(You n eed to dow nl oadnheifyuopce.) Somefast and powerful behavior is add

15、ed to browsers via plug-ins, but writing a plug-in is not a燕山大学本科生毕业设计(翻译)3trivial task, and isn t something you d want to do as paprocess of building a particular site. The value of the plug-in for client-side programming isthat it allows an expert programmer to develop a new language and add that

16、Ianguage to abrowser without the permission of the browser manufacturer. Thus, plug-ins provide a“ back door ” that allows the creation of new client-side programming Ianguages(although not all Ianguages are impleme nted as plug-i ns).3. Scripting languagesPlug-ins resulted in an explosion of script

17、ing languages. With a scripting Ian guage youembed the source code for your clie nt-side program directly into the HTML page, and theplug-in that interprets that language is automatically activated while the HTML page is beingdisplayed. Script ing lan guages tend to be reas on ably easy to un dersta

18、 nd and, becausethey are simply text that is part of an HTML page, they load very quickly as part of the sin gleserver hit required to procure that page. The trade-off is that your code is exposed for everyone to see (and steal). Gen erally, however, you aren t doingpamazatgiy thingswith scripting l

19、anguages so this is not too much of a hardship.This points out that the scripti ng lan guages used in side Web browsers are really in tended to solve specific types of problems, primarily the creati on of richer and more in teractivegraphical user in terfaces (GUIs). However, a scripting language mi

20、ght solve 80 percent ofthe problems encountered in clie nt-side program ming. Your problems might very well fitcompletely within that 80 percent, and since scripting languages can allow easier and fasterdevelopme nt, you should probably con sider a scripti ng lan guage before look ing at amore invo

21、Ived soluti on such as Java or ActiveX program ming.The most com monly discussed browser scripti ng lan guages are JavaScript (which hasnothing to do with Java; it s namthdat way just to grab some of Java marketingmomentum), VBScript (which looks like Visual Basic), andTcl/Tk, which comes from the p

22、opular cross-platform GUI-building Ianguage. There areothers out there, and no doubt more in developme nt.JavaScript is probably the most com monly supported. It comes built into both NetscapeNavigator and the Microsoft Internet Explorer (IE). I n additi on, there are probably more燕山大学本科生毕业设计(翻译)4Ja

23、vaScript books available than there are for the other browser Ian guages, and some toolsautomatically create pages using JavaScript. However, if you ralready flue nt in VisualBasic or Tcl/Tk, you lbe more productive using those scripting Ianguages rather thanlearning a new one. (You ll have your han

24、ds full dealingith the Web issues already.)4. JavaIf a scripting Ianguage can solve 80 percent of the client-side programming problems,what about the other 20 percent the “really hard stuff? ” The most popular solutiontoday is Java. Not only is it a powerful programming Ianguage built to be secure,c

25、ross-platform, and intern ati on al, but Java is being continually extended to provideIanguage features and libraries that elegantly han dle problems that are difficult in traditional program ming Ian guages, such as multithreading, database access, networkprogramming, and distributed computing. Jav

26、a allows client-side programming via theapplet.An applet is a mini-program that will run only under a Web browser. The applet is dow nloaded automatically as part of a Web page (just as, for example, a graphic is automaticallydow nl oaded). Whe n the applet is activated it executes a program. This i

27、s part of itsbeauty it provides you with a way to automatically distribute the clie nt software from theserver at the time the user n eeds the clie nt software, and no sooner. The user gets thelatest versi on of the client software without fail and without difficult reinstallation. Becauseofthe way

28、Java is desig ned, the programmer n eeds to create only a sin gle program, and thatprogram automatically works with all computers that have browsers with built-in Javainterpreters. (This safely includes the vast majority of machines.) Since Java is a full-fledgedprogramming Ianguage, you can do as m

29、uch work as possible on the client before and aftermaking requests of the server. For example, you won t need to send a request form acrossthe Internet to discover that you vegotten a date or some other parameter wrong, and yourclie nt computer can quickly do the work of plott ing data in stead of w

30、ait ing for the server tomake a plot and ship a graphic image back to you. Not only do you get the immediate win ofspeed and responsiveness,but the general network traffic and load on servers can bereduced, preventing the entire Internet from slowing down.燕山大学本科生毕业设计(翻译)5One advantage a Java applet

31、has over a scripted program is that it in compiled form, sothe source code isn t available to the client. On the other hara Java applet can be decompiled without too much trouble, but hid ing your code is often notan important issue. Two other factors can be important. As you will see later in this

32、book, acompiled Java applet can comprise many modules and take multiple server “ hits ”(accesses) to download. (In Java 1.1 and higher thisminimized by Java archives, called JAR files, that allow all the required modules to bepackaged together and compressed for a single download.) A scripted progra

33、m will just bein tegrated into the Web page as part of its text (and will gen erally be smaller and reduceserver hits). This could be importa nt to the responsivenessof your Web site. Another factoris the all-important learning curve. Regardless of what you ve heard, Java is not a triviallanguage to

34、 learn. If you re Visual Basic programmer, moving to VBScript will be yourfastest solution, and since it will probably solve most typical client/server problems youmight be hard pressed to justify learning Java. If you rexperieneed with a script ing Ianguage you will certa inly ben efit from look in

35、g at JavaScript or VBScript before committingto Java, since they might fit your needs handily and you ll be more productive sooner.to runits applets withi5. ActiveXTo some degree, the competitor to Java is Microsoft ActiveX, although it takes acompletely differe nt approach. ActiveX was origi nally

36、a Win dows-o nly solution, although itis now being developed via an independent consortium to become crossplatform.Effectively, ActiveX says“ if your program conn ectstoits environment just so, it can be dropped into a Web page and run under a browser thatsupports ActiveX. ”IE directly supports Acti

37、veX and Netscape does so using a plug-in.)Thus, ActiveX does not constrain you to a particular Ianguage. If, for example, you realready an experieneed Windows programmerusing a Ianguage such as C+, Visual Basic, or Borland s Delphi, you can create燕山大学本科生毕业设计(翻译)6ActiveX comp onents with almost no ch

38、a nges to your program ming kno wledge. ActiveXalso provides a path for the use of legacy code in your Web pages.6. SecurityAutomatically downloading and running programs across the Internet can sound like avirus-builder dream. ActiveX especially brings up the thorny issue of security in clie nt-sid

39、eprogram min g. If you click on a Web site, you might automatically download any number ofthings along with the HTML page: GIF files, script code, compiled Java code, and ActiveXcomp onen ts. Some of these are benign; GIF files can do any harm, and scriptingIanguages are gen erally limited in what t

40、hey can do. Java was also desig ned to run itsapplets within a“ san dbox ”fedf,swhich preve nts it from writi ng to disk or access ingmemory outside the san dbox.ActiveX is at the opposite end of the spectrum. Programmi ng with ActiveX is likeprogram ming Win dows you can do any thi ng you want. So

41、if you click on a page thatdownloads an ActiveX component, that component might cause damage to the files on yourdisk. Of course, programs that you load onto your computer that are not restricted to runningin side a Web browser can do the same thing. Viruses downloaded from Bulletin-BoardSystems (BB

42、Ss) have long bee n a problem, but the speed of the Internet amplifies thedifficulty.The soluti on seems to be “ digitalsig natures, whereby code is verified to show who theauthor is. This is based on the idea that a virus works because its creator can beanonymous, so if you remove the anonymity ind

43、ividuals will be forced to be resp on sible fortheir actions. This seems like a good pla n because it allows programs to be much more functi on al, and I suspect it will elim in ate malicious mischief. If, however, a program has anuninten ti onal destructive bugit will still cause problems.The Java

44、approach is to prevent these problems from occurring, via the san dbox. TheJava in terpreter that lives on your local Web browser exam ines the applet for any untoward in struct ions as the applet is being loaded. In particular, the applet cannot write filesto disk or erase files (one of the main st

45、ays of viruses). Applets are gen erally con sidered to燕山大学本科生毕业设计(翻译)7be safe, and since this is esse ntial for reliable client/server systems, any bugs in the JavaIanguage that allow viruses are rapidly repaired. (It s worth noting that the browsersoftware actuaen forces these security restrict ion

46、s, and some browsers allow you to select differe ntsecurity levels to provide vary ing degrees of access to your system.)You might be skeptical of this rather draconian restriction against writing files to your localdisk. For example, you may want to build a local database or save data for later use

47、 offline.The initial vision seemed to be that eventually every one would get on li ne to do anythingimporta nt, but that was soon see n to be impractical (although low-cost“Internefeppliances ” mighrtmeday satisfy the n eeds of a sig nifica nt segme nt of users).The soluti on is the“ sigithat uses p

48、ublic-key en crypti on to verify that an applet does in deed come from where itclaims it does. A signed applet can still trash your disk, but the theory is that since you cannow hold the applet creator accountable they won t(thin gs. Java provides a framework for digital sig natures so that you will

49、 eve ntually be ableto allow an applet to step outside the san dbox if n ecessary.Digital sig natures have missed an importa nt issue, which is the speed that people movearound on the Internet. If you download a buggy program and it does someth ing un toward,how long will it be before you discover t

50、he damage? It could be days or eve n weeks. By then, how will you track dow n the program that s done it? And what good will it do you at thatpoint?7 ln ternet vs. i ntranetThe Web is the most general solution to the client/server problem, so it makes sense thatyou can use the same tech no logy to s

51、olve a subset of the problem, in particular the classicclient/server problem within a company. With traditional client/server approaches you havethe problem of multiple types of client computers, as well as the difficulty of installing newclient software, both of which are handily solved with Web br

52、owsers and client-side燕山大学本科生毕业设计(翻译)8programming. When Web tech no logy is used for an in formatio n n etwork that is restrictedto a particular company, it is referred to as an intranet. Intranets provide much greatersecurity tha n the Intern et, since you can physically con trol access to the serv

53、ers withinyour company. In terms of training, it seems that once people understand the generalconcept of a browser it s much easier for them to deal with differe nces in the way pagesand applets look, so the lear ning curve for new kinds of systems seems to be reduced.The security problem brings us

54、to one of the divisions that seems to be automaticallyformi ng in the world of clie nt-side program min g. If your program is running on the Internet,you don know what platform it will be working un der, and you want to be extra careful thatyou don ssem in atebugy code. You need something cross-plat

55、form and secure, like ascripting Ianguage or Java.If you re running on an intranet, you might have a different set of constraints. It s notun com mon that your machi nes could all be In tel/Wi ndows platfer On an intranet, you reresponsible for the quality of your own code and can repair bugs when t

56、hey discovered. Inaddition, you might already have a body of legacy code that you ve been using in a moretraditional client/server approach, whereby you must physically in stall clie nt programsevery time you do an upgrade. The time wasted in installing upgrades is the mostcompelling reason to move

57、to browsers, because upgrades are inv isible and automatic. Ifyou are invo Ived in such an intran et, the most sen sible approach to take is the shortestpath that allows you to use your existing code base, rather than trying to recode yourprograms in a new Ian guage.When faced with this bewildering

58、array of solutions to the client-side programmingproblem, the best plan of attack is a cost-benefit analysis. Con sider the con stra ints of yourproblem and what would be the shortest path to your solutio n. Since clie nt-side programming is still program min g, it s alwaysgood idea to take the fast

59、est developme nt approach for your particular situati on.This is an aggressive sta nee to prepare for in evitable encoun ters with the problems ofprogram developme nt.燕山大学本科生毕业设计(翻译)98. Server-side programmingThis whole discussion has ignored the issue of server-side programming. What happenswhen yo

60、u make a request of a server? Most of the time the request is simply “ sendne thisfile. Your browser then interprets the file in some appropriate fashi on: as an HTML page, agraphic image, a Java applet, a script program, etc. A more complicated request to a servergen erally invo Ives a database tra

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论