JAVA外文文献+翻译

上传人:h****M 文档编号:46995711 上传时间:2021-12-16 格式:DOCX 页数:33 大小:50.28KB
返回 下载 相关 举报
JAVA外文文献+翻译_第1页
第1页 / 共33页
JAVA外文文献+翻译_第2页
第2页 / 共33页
JAVA外文文献+翻译_第3页
第3页 / 共33页
点击查看更多>>
资源描述
Java and the InternetIf Java is, in fact, yet another computer programming Ianguage, you may question why itis so importantandwhyit is beingpromotedas a revolutionarystepin computerprogramming. The answer isn t immediately obvious if you coming from a traditional programming perspective. 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 teractivity 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 on that can only be programmed to reset the dataon 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 program located on the server in a directorythats 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 choice because it is designed 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 programs 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.) Thein 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 the 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 HTML page informing you of the error, and then sends the page back to you; you must the n back up apage and try aga in. Not only is this slow, its inelegant.The solution is client-sideprogramming.Most machinesthat run Web browsersarepowerful engines capable of doing vast work, and with the origi nal static HTML approachthey 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 site.The problem with discussions of client-side prog ramming is that they aren t verydiffere 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, and 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-i nsOne of the most significant steps forward in client-side programming is the development 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. Ittells the browser “ from now on yperform this new activity.(You n eed to dow nl oadnheifyuopce.) Somefast and powerful behavior is added to browsers via plug-ins, but writing a plug-in is not atrivial task, and isn t something youd 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 and add that Ianguage to a browser without the permission of the browser manufacturer. Thus, plug-ins provide a“ back door ” that allows the creation ofnew client-side programming Ianguages (although not all Ianguages are impleme nted as plug-i ns).3.Scripting languagesPlug-ins resulted in an explosion of scripting languages. With a scripting lan guage you embed 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 being displayed. Script ing lan guages tend to be reas on ably 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 isexposed for every one to see (and steal). Gen erally, however, you aren t doingpamazatgiy thingswith 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 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 before 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 (whichhas nothing to do with Java; its namthdat way just to grab some of Javamarketingmomentum), VBScript (which looks like Visual Basic), andTcl/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 NetscapeNavigator and the Microsoft Internet Explorer (IE). I n additi on, there are probably more JavaScript books available than there are for the other browser Ian guages, and sometools 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. (You 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 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 distributed 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 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 reinstallation. 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 programming Ianguage, you can do as much work as possible on the client before and after making requests of the server. For example, youwon 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 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 thegeneral network traffic and load on servers can be reduced, preventing the entire Internet from slowing down.One 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 har a 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 you 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 higherthisminimized by Java archives, called JAR files, that allow all the required modules to be packaged together and compressed for a single 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. Anotherfactor is the all-important learning curve. Regardless of what youve heard, Java is not atrivial 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 problemsyou might be hard pressed to justify learning Java. If yourexperieneed with a script ingIan guage you will certa inly ben efit from look ing at JavaScript or VBScript beforecommitting to Java, since they might fit your needs handily and youll be more productivesooner.to run its applets withi5.ActiveXTo some degree, the competitor to Java is Microsoft ActiveX, although it takes a completely differe 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 supports 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, youalready an experieneed Windows programmerusing a Ianguage such as C+, Visual Basic, or Borlands Delphi, you can createreActiveX comp 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 issue 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 Ianguages 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 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 downloaded 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 anonymous, 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 destructive bugit will still cause problems.The Java 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 un toward in struct ions as the applet is being loaded. In particular, the applet cannot write 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 bugsin the Java Ianguage that allow viruses are rapidly repaired. (It s worth noting that the browser software actuaen 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 local 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 users). 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 cannow hold the applet creator accountable they won t(thin gs. Java provides a framework 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 toward, how long will it be before you discover the damage? It could be days or eve nweeks. By the n, how will you track dow n the program thats done it? And what goodwill it do you at that point?7.ln ter net vs. intranetThe Web is the most general solution to the client/server problem, so it makes 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 approachesyou have the problem of multiple types of client computers, as well as the difficulty of installing new client software, 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 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 theway pages and applets look, so the lear ning curve for new kinds of systems seems to 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 extracareful that you don ssem in atebugy code. You need something cross-platform andsecure, like a scripting Ianguage or Java.If you re running on an intranet, you might have a different set of constraints. Itsnot un com mon that your machi nes could all be In tel/Wi ndows platfer On an intranet,you re responsible for the quality of your own code and can repair bugs when theydiscovered. In addition, you might already have a body of legacy code that youve beenusing 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 installing 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 programs 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-sideprogram ming is still program min g, its 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 program mingThis 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 file. Your browser then interprets the file in some appropriate fashi on: asan HTML page, a graphic image, a Java applet, a script program, etc. A more complicated request to a server gen erally invo Ives a database tran sact ion. A com mon sce nario invo Ives a request for a complex database search, which the server the n formats into an HTML page and sends to you as the result. (Of course, if the clie nt has more in tellige nee via Java or a scripting Ianguage, the raw data can be sent and formatted at the client end, which will be faster and less load on the server.) Or you might want to register your name in a database whenyou join a group or place an order, which will invo Ive cha nges to that database. These database requests must be processed via some code on the server side, which is gen erally referred to as server-side program ming. Traditi on ally, server-side program ming has bee n performed using Perl and CGI scripts, but more sophisticated systems have bee n appeari ng. These include Java-based Web servers that allow you to perform all your server-side programming in Java by writing what are called servlets. Servlets and their offspri ng, JSPs, are two of the most comp
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 管理文书 > 各类标准


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!