版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、燕山大学本科生毕业设计(翻译)Java and the InternetIf Java is, in fact, yet another computer programming Ianguage, you may question why it is so important and why it is being promoted as a revolutionary step in computer programming. The answer isn t immediately obvious if youcoming from a traditional programming p
2、erspective. Although Java is very useful for solving traditional stand-alone programming problems, it is also importa nt because it will solve program 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 in te
3、ractivity was completely provided by the server. The server produced static pages for the client browser, which would simply interpret and display them. Basic HTML contains simple mechanismsfor data gathering: text-entry boxes, check boxes, radio boxes, lists and drop-dow n lists, as well as a butt
4、on that can only be programmed to reset the data on the form or“ submiton the form back to the server. This submissi on passesthrough the Com mon Gateway In terface (CGI) provided on all Web servers. The text within the submissi on tells CGI what to do with it. The most com mon actio n is to run a p
5、rogram located on the server in a directory that s typ-caily calledyou watch the addresswindow at the top of your browser when you push a butt on on a Web page, you can sometimes see “ cgb in ” with in all the gobbledygook there.) These programs can be writte n in most la nguages. Perl is a com mon
6、choice because it is desig ned for text mani pulati on and is in terpreted, so it can be in stalled on any server regardless of processor or operat ing system.Many powerful Web sites today are built strictly on CGI, and you can in fact do nearly anything with it. However, Web sites built on CGI prog
7、rams can rapidly become overly complicated to main tai n, and there is also the problem of resp onse time. The resp onse of a CGI program depe nds on how much data must be sent, as well as the load on both the server and the Intern et. (On top of this, start ing a CGI program tends to be slow.) The
8、in itial desig ners of the Web did not foresee how rapidly this bandwidth would be exhausted for the kinds of applicati ons people developed. For example, any sort of dyn amic graph ing is nearly impossible to perform with consistency because a GIF file must be created and moved from the server to t
9、he clie nt for each versi on of the graph. And you veno doubt had direct experienee with something as simple as validat ing the data on an in put form. You press the submit butt on on a page; the data is shipped back to the server; the server starts a CGI program that discovers an error, formats an
10、HTML page 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. Not only is this slow, it s inelegant.The solution is client-side programming. Most machines that run Web browsers are powerful engines capable of doing vast work, and with the or
11、igi nal static HTML approach they are sitting there, just idly waiting for the server to dish up the n ext page. Clie nt-side program ming means that the Web browser is harnessedto do whatever work it can, and the result for the user is a much speedier and more in teractive experie nee at your Web s
12、ite.The problem with discussions of client-side prog ramming is that they aren t very differe nt from discussi ons of program ming in gen eral. The parameters are almost the same, but the platform is different: a Web browser is like a limited operati ng system .In the end, you must still program, an
13、d this acco unts for the dizzy ing array of problems and soluti ons produced by clie nt-side program ming. The rest of this sect ion provides an overview of the issues and approachesi n clie nt-side program ming.2. Plug-insOne of the most significant steps forward in client-side programming is the d
14、evelopment of the plug-in. This is a way for a programmer to add new functionality to the browser by downloading a piece of code that plugs itself into the appropriate spot in the browser. It tells the browser“ from now on yperform this new activity.(You n eed to dow nl oadnheifyuopce.) Somefast and
15、 powerful behavior is added to browsers via plug-ins, but writing a plug-in is not a trivial 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 is that it allows an expert programmer to develop a new language an
16、d add that Ianguage to a browser 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 explo
17、sion of scripting languages. With a scripting Ian guage you embed the source code for your clie nt-side program directly into the HTML page, and the plug-in that interprets that language is automatically activated while the HTML page is being displayed. Script ing lan guages tend to be reas on ably
18、easy to un dersta nd and, because they are simply text that is part of an HTML page, they load very quickly as part of the sin gle server hit required to procure that page. The trade-off is that your code is exposed for every one to see (and steal). Gen erally, however, you aren t doingpamazatgiy th
19、ingswith scripting languages 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 ten ded to solve specific types of problems, primarily the creati on of richer and more in teractive graphical user in terfaces (GUIs). However, a
20、 scripting language might solve 80 percent of the problems encountered in clie nt-side program ming. Your problems might very well fit completely within that 80 percent, and since scripting languages can allow easier and faster developme nt, you should probably con sider a scripti ng lan guage befor
21、e look ing at a more invo Ived soluti on such as Java or ActiveX program ming.The most com monly discussed browser scripti ng lan guages are JavaScript (which has nothing to do with Java; it s namthdat way just to grab some of Java marketing momentum), VBScript (which looks like Visual Basic), andTc
22、l/Tk, which comes from the popular cross-platform GUI-building Ianguage. There are others out there, and no doubt more in developme nt.JavaScript is probably the most com monly supported. It comes built into both Netscape Navigator and the Microsoft Internet Explorer (IE). I n additi on, there are p
23、robably more JavaScript books available than there are for the other browser Ian guages, and some tools automatically create pages using JavaScript. However, if you ralready flue nt in Visual Basic or Tcl/Tk, you lbe more productive using those scripting Ianguages rather than learning a new one. (Yo
24、u ll have your hands 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 solution today is Java. Not only is it a powerful programming Ianguage
25、built to be secure, cross-platform, and intern ati on al, but Java is being continually extended to provide Ianguage features and libraries that elegantly han dle problems that are difficult in traditi onal program ming Ian guages, such as multithreading, database access, network programming, and di
26、stributed computing. Java allows client-side programming via the applet.An applet is a mini-program that will run only under a Web browser. The applet is dow nl oaded automatically as part of a Web page (just as, for example, a graphic is automatically dow nl oaded). Whe n the applet is activated it
27、 executes a program. This is part of its beauty it provides you with a way to automatically distribute the clie nt software from the server at the time the user n eeds the clie nt software, and no sooner. The user gets the latest versi on of the client software without fail and without difficult rei
28、nstallation. Becauseof the way Java is desig ned, the programmer n eeds to create only a sin gle program, and that program automatically works with all computers that have browsers with built-in Java interpreters. (This safely includes the vast majority of machines.) Since Java is a full-fledged pro
29、gramming Ianguage, you can do as much work as possible on the client before and after making requests of the server. For example, you won t need to send a request form across the Internet to discover that you vegotten a date or some other parameter wrong, and your clie nt computer can quickly do the
30、 work of plott ing data in stead of wait ing for the server to make a plot and ship a graphic image back to you. Not only do you get the immediate win of speed and responsiveness,but the general network traffic and load on servers can be reduced, preventing the entire Internet from slowing down.One
31、advantage a Java applet has over a scripted program is that it in compiled form, so the 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 not an important issue. Two other factors can be important. As y
32、ou will see later in this book, a compiled 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 be packaged together and compressed for a single
33、download.) A scripted program will just be in tegrated into the Web page as part of its text (and will gen erally be smaller and reduce server hits). This could be importa nt to the responsivenessof your Web site. Another factor is the all-important learning curve. Regardless of what you ve heard, J
34、ava is not a trivial language to learn. If you re Visual Basic programmer, moving to VBScript will be your fastest solution, and since it will probably solve most typical client/server problems you might be hard pressed to justify learning Java. If you rexperieneed with a script ing Ian guage you wi
35、ll certa inly ben efit from look ing at JavaScript or VBScript before committing to Java, since they might fit your needs handily and you ll be more productive sooner.to run its applets withi5. ActiveXTo some degree, the competitor to Java is Microsoft ActiveX, although it takes a completely differe
36、 nt approach. ActiveX was origi nally a Win dows-o nly solution, although it is now being developed via an independent consortium to become crossplatform. Effectively, ActiveX says“ if your program conn ects toits environment just so, it can be dropped into a Web page and run under a browser that su
37、pports ActiveX. ”IE directly supports ActiveX and Netscape does so using a plug-in.) Thus, ActiveX does not constrain you to a particular Ianguage. If, for example, you re already an experieneed Windows programmerusing a Ianguage such as C+, Visual Basic, or Borland s Delphi, you can createActiveX c
38、omp onents with almost no cha nges to your program ming kno wledge. ActiveX also 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 a virus-builder dream. ActiveX especially brings up the thorny is
39、sue of security in clie nt-side program min g. If you click on a Web site, you might automatically download any number of things along with the HTML page: GIF files, script code, compiled Java code, and ActiveX comp onen ts. Some of these are benign; GIF files can do any harm, and scripting Ianguage
40、s are gen erally limited in what they can do. Java was also desig ned to run its applets 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 like program ming Win dows
41、 you can do any thi ng you want. So if you click on a page that downloads an ActiveX component, that component might cause damage to the files on your disk. Of course, programs that you load onto your computer that are not restricted to running in side a Web browser can do the same thing. Viruses do
42、wnloaded from Bulletin-Board Systems (BBSs) have long bee n a problem, but the speed of the Internet amplifies the difficulty.The soluti on seems to be “ digitalsig natures, whereby code is verified to show who the author is. This is based on the idea that a virus works because its creator can be an
43、onymous, so if you remove the anonymity individuals will be forced to be resp on sible for their actions. This seems like a good pla n because it allows programs to be much more fun cti on al, and I suspect it will elim in ate malicious mischief. If, however, a program has an uninten ti onal destruc
44、tive bugit will still cause problems.The Java approach is to prevent these problems from occurring, via the san dbox. The Java in terpreter that lives on your local Web browser exam ines the applet for any un toward in struct ions as the applet is being loaded. In particular, the applet cannot write
45、 files to disk or erase files (one of the main stays of viruses). Applets are gen erally con sidered to be safe, and since this is esse ntial for reliable client/server systems, any bugs in the Java Ianguage that allow viruses are rapidly repaired. (It s worth noting that the browser software actuae
46、n forces these security restrict ions, and some browsers allow you to select differe nt security 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 local disk. For example, you may want to build a loc
47、al database or save data for later use offline. The initial vision seemed to be that eventually every one would get on li ne to do anything importa 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 use
48、rs). The soluti on is the“ sigithat uses public-key en crypti on to verify that an applet does in deed come from where it claims it does. A signed applet can still trash your disk, but the theory is that since you can now hold the applet creator accountable they won t(thin gs. Java provides a framew
49、ork for digital sig natures so that you will eve ntually be able to 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 move around on the Internet. If you download a buggy program and it does someth ing un to
50、ward, how long will it be before you discover the damage? It could be days or eve n weeks. By the n, how will you track dow n the program that s done it? And what good will it do you at that point?7ln ternet vs. i ntranetThe Web is the most general solution to the client/server problem, so it makes
51、sense that you can use the same tech no logy to solve a subset of the problem, in particular the classic client/server problem within a company. With traditional client/server approaches you have the problem of multiple types of client computers, as well as the difficulty of installing new client so
52、ftware, both of which are handily solved with Web browsers and client-side programming. When Web tech no logy is used for an in formatio n n etwork that is restricted to a particular company, it is referred to as an intranet. Intranets provide much greater security tha n the Intern et, since you can
53、 physically con trol access to the servers within your company. In terms of training, it seems that once people understand the general concept of a browser it s much easier for them to deal with differe nces in the way pages and applets look, so the lear ning curve for new kinds of systems seems to
54、be reduced.The security problem brings us to one of the divisions that seems to be automatically formi 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 that you don ssem i
55、n atebugy code. You need something cross-platform and secure, like a scripting Ianguage or Java.If you re running on an intranet, you might have a different set of constraints. It s not un com mon that your machi nes could all be In tel/Wi ndows platfer On an intranet, you re responsible for the qua
56、lity of your own code and can repair bugs when they discovered. In addition, you might already have a body of legacy code that you ve been using in a more traditional client/server approach, whereby you must physically in stall clie nt programs every time you do an upgrade. The time wasted in instal
57、ling upgrades is the most compelling reason to move to browsers, because upgrades are inv isible and automatic. If you are invo Ived in such an intran et, the most sen sible approach to take is the shortest path that allows you to use your existing code base, rather than trying to recode your progra
58、ms in a new Ian guage.When faced with this bewildering array of solutions to the client-side programming problem, the best plan of attack is a cost-benefit analysis. Con sider the con stra ints of your problem and what would be the shortest path to your solutio n. Since clie nt-side program ming is
59、still program min g, it s alwaysgood idea to take the fastest developme nt approach for your particular situati on.This is an aggressive sta nee to prepare for in evitable encoun ters with the problems of program developme nt.8. Server-side programmingThis whole discussion has ignored the issue of server-side programming. What happens when you make a request of a server? Most of the time the request is simply “ sendne this fi
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 酒店综合技能试题及答案
- 烘焙行业考试试题及答案
- 2026年房产中介服务经销合同书
- 2025年宁波市奉化区农商控股集团有限公司招聘笔试真题
- 【二年级下册数学】【通 用版】时、分、秒计算专项
- 北京东城区属国有企业招聘考试真题2025
- 施工现场材料采购供应管理规范
- 小学语文课件 识字教学融入传统文化渗透汉字文化内涵
- 小学音乐中年级演唱技能提升教学设计
- 小学三年级下册体育基础动作与游戏教学设计
- 苹果园防雹网设计及架设技术规程
- 中国音乐历史课件
- 中辐放射性药物贮存及销售项目环评资料环境影响
- 部编版七年级下册语文基础知识专项练习题100题(含答案)
- 中建坡屋面悬挑檐口施工方案
- 改性塑料设备及工艺
- 乔木支撑架施工方案
- 急性左心衰的护理查房
- 沼气发电示范工程工程可研报告(完整版)资料
- GB/T 9276-1996涂层自然气候曝露试验方法
- 管理心理学的理论与分析课件
评论
0/150
提交评论