版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、JavaandInternetIf Java is, in fact, yet another computer programming Ianguage, you may question why it is so imp orta nt and why it is being pro moted as a revoluti onary ste p in compu ter p rogram ming. The an swer isn ' t immediately obvious if you coming'froen a traditional programming p
2、erspective. Although Java is very useful for sol ving traditi onal sta nd-al one p rogram ming p roblems, it is also imp orta nt because it will solve p rogram ming p roblems on the World Wide Web.1. Client-side programmingThe Web snitial serve-browser desig n pro vided for in teractive content, but
3、 the in teractivity was com pl etely p rovided by the server. The server p roduced static p ages for the clie nt browser, which would simp ly in terpret and dis play them. Basic HTML contains sim pie mecha ni sms for data gatheri ng: text-e ntry boxes, check boxes, radio boxes, lists and drop-dow n
4、lists, as well as a butt on that can only be programmed to reset the data on the form or “ submit ”e data on the form back to the server. This submissi on p asses through the Com mon Gateway In terface (CGI) p rovided on all Web servers. The text within the submissi on tells CGI what to do with it.
5、The most com mon actio n is to run a p rogram located on the server in a directory that' s typicallybiralied (Ifou wafotgthe address window at the topof your browser whe n you p ush a butt on on a Web p age, you can sometimes see -bin ” withi n acghe gobbledygook there.) These p rograms can be w
6、ritte n in most Ian guages. Perl is a com mon choice because it is desig ned for text manipu lati on and is interp reted, so it can be in stalled on any server regardless of p rocessor or op erati ng system.Many po werful Web sites today are built strictly on CGI, and you can in fact do n early any
7、thi ng with it. However, Web sites built on CGI p rograms can rap idly become overly comp licated to maintain, and there is also the p roblem of res ponse time. The res ponse of a CGI p rogram depends on how much data must be sent, as well as the load on both the server and the Intern et. (On top of
8、 this, start ing a CGI p rogram tends to be slow.) The in itial desig ners of the Web did not foresee how rap idly this ban dwidth would be exhausted for the kinds of app licati ons people devel op ed. For exa mp le, any sort of dyn amic graphing is n early imp ossible to p erform with con siste ncy
9、 because a GIF file must be created and moved from the server to the client for each version of the graph. And you' veio doubt had direct experienee with someth ing as simple as validat ing the data on an input form. You p ress the submit butt on on a p age; the data is shipped back to the serve
10、r; the server starts a CGI p rogram that discovers an error, formats an HTML p age informing you of the error, and the n sends the p age back to you; you must the n back up a page and try again. Not only isthis slow, it ' s inelegant.The soluti on is clie nt-side p rogram ming. Most mach ines th
11、at run Web browsers are po werful engines cap able of doing vast work, and with the orig inal static HTML app roach they are sitt ing there, just idly wait ing for the server to dish up the n ext p age. Clie nt-side p rogram ming mea ns that the Web browser is harn essed to do whatever work it can,
12、and the result for the user is a much sp eedier and more in teractive exp erie nee at your Web site.The problem with discussions of client-side programming is that they aren ' Very different from discussi ons of p rogram ming in gen eral. The p arameters are almost the same, but the p latform is
13、 differe nt: a Web browser is like a limited op erati ng system .In the end, you must still p rogram, and this acco unts for the dizzying array of problems and solutions produced by client-side programming. The rest of this secti on p rovides an overview of the issues and app roaches in clie nt-side
14、 p rogram ming.One of the most sig nifica nt ste ps forward in clie nt-side p rogram ming is the devel opment of the pl ug-i n. This is a way for a p rogrammer to add new fun ctio nality to the browser by dow nl oad ing a p iece of code that plugs itself into the appropriate spot in the browser. It
15、tells the browser “ fromnow on you can perform this new activity. (You need to download the plug-in only once.) Some fast and powerful behavior is added to browsers via plug-ins, but writing a plug- in is not a trivial task, and isn' t somyou' dwant to do as part of the process of building a
16、 particular site. The value of the plug-in for clie nt-side p rogram ming is that it allows an expert p rogrammer to devel op a new Ian guage and add that Ian guage to a browser without the p ermissi on of the browser manu facturer. Thus, pl ug-i ns pro vide a“ backdoor ” that allows the creation of
17、 new client-side programming Ianguages (although not all Ian guages are imp leme nted as pl ug-i ns).Ian guagesPIug-ins resulted in an explosion of scripting Ianguages. With a scripting Ianguage you embed the source code for your clie nt-side p rogram directly into the HTML p age, and the pl ug-i n
18、that in terprets that Ian guage is automatically activated while the HTML p age is being dis played. Scrip ti ng Ian guages tend to be reas on ably easy to un dersta nd and, because they are sim ply text that is part of an HTML p age, they load very quickly as part of the sin gle server hit required
19、 to p rocure that p age. The trade-off is that your code is exp osed for every one to see (and steal). Gen erally, however, you aren ' doing amaz in gly sop histicated things with scri pti ng Ian guages so this is not too much of a hardsh ip.This points out that the scri pti ng Ian guages used i
20、n side Web browsers are really inten ded to solve sp ecific types of p roblems, p rimarily the creati on of richer and more in teractive grap hical user in terfaces (GUIs). However, a scri pting Ian guage might solve 80 p erce nt of the p roblems encoun tered in clie nt-side p rogram ming. Your p ro
21、blems might very well fit comp letely withi n that 80 p erce nt, and since scri pting Ian guages can allow easier and faster devel opment, you should p robably con sider a scri pti ng Ian guage before look ing at a more invo Ived solutio n such as Java or ActiveX p rogram ming.The most commonly disc
22、ussed browser scripting Ianguages are JavaScript (which has nothing to do with Java; it ' s named that way just to grab some of Java' s marketing momentum), VBScript (whi( like Visual Basic), and Tcl/Tk, which comes from the popular cross-platform GUI-building Ianguage. There are others out
23、there, and no doubt more in devel opment.JavaScri pt is p robably the most com monly supp orted. It comes built into both Netsca pe Navigator and the Microsoft Internet Explorer (IE). I n additi on, there are p robably more JavaScri pt books available tha n there are for the other browser Ian guages
24、, and some tools automatically create p agesus ing JavaScri pt. However, if you' redready flue nt in Visual Basic or Tcl/Tk, you' lbe more p roductive using those scripting Ianguages rather than learning a new one. (You have yoilr hands full dealing with the Web issues already.)If a scri pti
25、 ng Ian guage can solve 80 p erce nt of the clie nt-side p rogram ming p roblems, what about the other 20 percen the “reallyhard stuff The most popular solution today is Java. Not only is it a po werful p rogram ming Ian guage built to be secure, cross-p latform, and intern ati on al, but Java is be
26、ing con ti nu ally exte nded to p rovide Ian guage features and libraries that elega ntly han dle p roblems that are difficult in traditional programming Ianguages, such as multithreading, database access, network p rogram ming, and distributed compu ti ng. Java allows clie nt-side p rogram ming via
27、 the app let.An applet is a mini-program that will run only under a Web browser. The applet is downloaded automatically as part of a Web p age (just as, for exa mp le, a grap hic is automatically dow nl oaded). When the app let is activated it executes a p rogram. This is part of its beauty it pro v
28、ides 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 version of the client software without fail and without difficult rein stallatio n. Because of the way Java is desig ned, the
29、 p rogrammer n eeds to create only a sin gle p rogram, and that program automatically works with all computers that have browsers with built-in Java in terpreters. (This safely in cludes the vast majority of mach in es.) Si nee Java is a full-fledged programming Ianguage, you can do as much work as
30、possible on the client before and after making requests of theserver. For example, you won ' t need to send a request form across the Internet to discov that you ' ve gotten a date or some other parameter wrong, and your client computer can quickly do the work of pl ott ing data in stead of
31、wait ing for the server to make a plot and ship a grap hic image back to you. Not only do you get the immediate win of sp eed and res pon sive ness, but the gen eral n etwork traffic and load on servers can be reduced, p reve nti ng the en tire Internet from slow ing dow n.One advantage a Java appet
32、 has over a scripted program is that it' s in compiled form, so the scode isn ' t available to the client. On the other hand, a Java applet can be decompiled without too much trouble, but hid ing your code is ofte n not an imp orta nt issue. Two other factors can be imp orta nt. As you will
33、see later in this book, a comp iled Java app let can comp rise many modules and take multi pie server“ hits ” (accesses) to download. (In Javad higher this is minimized by Java archives, called JAR files, that allow all the required modules to be p ackaged together and comp ressed for a sin gle dow
34、nl oad.) A scri pted p rogram will just be in tegrated into the Web p age as part of its text (and will gen erally be smallerand reduce server hits). This could be imp orta nt to the res pon sive ness of your Web site. Ano ther factor is the all-important learning curve. Regardless of what you'
35、ve heard, Java is not a trivial language tcIf you ' re a Visual Basic programmer, moving to VBScript will be your fastest solution, and since it Wil p robably solve most typ ical clie nt/server p roblems you might be hard p ressed to justify lear ning Java. If you' rexp erie need with a scri
36、 pting Ian guage you will certa inly ben efit from look ing at JavaScri pt or VBScript before committing to Java, since they might fit your needs handily and you' llbe more p roductive run its app lets withiTo some degree, the competitor to Java is Microsoft' s ActiveX, although it takes a c
37、ompletely(app roach. ActiveX was origi nally a Win dows-on ly solutio n, although it is now being devel oped via an independent con sortium to become crossplatform. Effectively, ActiveX says“ if your p rogram conneto its environment just so, it can be dropped into a Web page and run under a browser
38、that supports ActiveX. ” (IE directlyupports ActiveX 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 programmer using a Ianguage such as C+, Visual Basic, or Borland' siDcedphi Active
39、Xcomponents with almost no cha nges to your p rogram ming kno wledge. ActiveX also p rovides a p ath for the use of legacy code in your Web p ages.Automatically downloading and running programs across the Internet can sound like a virus-builder s' dream. ActiveX esp ecially brings up the thor ny
40、 issue of security in clie nt-side p rogram min g. If you click on a Web site, you might automatically dow nl oad any nu mber of thi ngs along with the HTML p age: GIF files, scri pt code, comp iled Java code, and ActieX componen ts. Some of these are benign; GIF files can do any harm, and scri pti
41、ng Ian guages are gen erally limited in what they can do. Java was also desig ned to run its app lets with in a“ san dbox ” of safety, which p reve nts it from writ ing to diskigmaecearyoutside the san dbox.ActiveX is at the opposite end of the spectrum. Programming with ActiveX is like programming
42、Windowsyou can do anything 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, p rograms that you load onto your compu ter that are not restricted to running in side a Web browser can do the same thing. Viru
43、ses dow nl oaded from Bulleti n-Board Systems (BBSs) have long bee n a p roblem, but the sp eed of the Internet amp lifies the difficulty.The soluti on seems to be“ digital sig natures, ” whereby code is verified to show who the authois based on the idea that a virus works because its creator can be
44、 anonymous, so if you remove the anonymity individuals will be forced to be responsible for their actions. This seems like a good plan because it allows p rograms to be much more fun cti on al, and I sus pect it will elim in ate malicious mischief.If, however, a p rogram has an uninten ti onal destr
45、uctive bug it will still cause p roblems.The Java app roach is to p reve nt these p roblems from occurri ng, via the san dbox. The Java interp reter that lives on your local Web browser exam ines the applet for any un toward in structi ons as the app let is being loaded. In p articular, the app let
46、cannot write files to disk or erase files (one of the main stays of viruses). AppI ets are gen erally con sidered to be safe, and since this is esse ntial for reliable clie nt/server systems, any bugs in the Java Ian guage that allow virues are rap idly rep aired. (It' s worth noting thatbrowser
47、 software actually enforces these security restrictions, and some browsers allow you to select differe nt security levels to pro vide vary ing degrees of access to your system.)You might be ske ptical of this rather drac onian restrictio n aga inst writi ng files to your local disk. For example, you
48、 may want to build a local databaseor save data for later use offline. The initial vision seemed to be that eve ntually every one would get on li ne to do anything imp orta nt, but that was soon see n to be impractical (although low- cost “Internetappliances might someday satisfy the needs of a sig
49、nifica nt segme nt of users). The soluti on is the“ sig ned app-ktey en cryptiuae® pubfcthat an app let does in deed come from where it claims it does. A sig ned app let can still trash your disk, but the theory is that since you can now hold the applet creator accountable they won' t do vp
50、 rovides a framework for digital sig natures so that you will eve ntually be able to allow an app let to ste p outside the san dbox if n ecessary.Digital sig natures have missed an imp orta nt issue, which is the sp eed that people move around on the Intern et. If you dow nl oad a buggy p rogram and
51、 it does somethi ng un toward, 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 p rogram that ' s done it And what good will it do you at that pointvs. intranetThe Web is the most gen eral soluti on to the clie nt/server p
52、 roblem, so it makes sense that you can use the same tech no logy to solve a subset of the p roblem, in p articular the classic clie nt/server p roblem with in a company. With traditional client/server approachesyou have the problem of multiple types of client compu ters, as well as the difficulty o
53、f in stalli ng new clie nt software, both of which are han dily solved with Web browsers and clie nt-side p rogram ming. When Web tech no logy is used for an in formati on n etwork that is restricted to a p articular company, it is referred to as an intran et. Intran ets pro vide much greater securi
54、ty than the Internet, since you can physically control accessto the servers within your company. In terms of training, it seems that once people understand the general concepf a browser it ' s much easier for them to deal with differe nces in the way p ages and app lets look, so the lear ning cu
55、rve for new kinds of systems seems to be reduced.The security p roblem brings us to one of the divisio ns that seems to be automatically formi ng in the world of client-side programming. If your program is running on the Internet, you don' know what platform it will be working under, and you wan
56、t to be extra careful that you don' t dissei You n eed someth ing cross-pl atform and secure, like a scri pti ng Ian guage or Java.If you ' re running on an intranet, you might have a different set of constraints. It'your machines could all be Intel/Windows platforms. On an intranet, you
57、' re responsible for tyour own code and can rep air bugs whe n they' re discovered. In additi on, you might already have a b(of legacy code that you' vbeen using in a more traditional client/server approach, whereby you must p hysically in stall clie nt p rograms every time you do an up
58、grade. The time wasted in in stalli ng up grades is the most comp elli ng reas on to move to browsers, because up grades are inv isible and automatic. If you are invo Ived in such an intran et, the most sen sible app roach to take is the shortest p ath that allows you to use your existi ng code base
59、, rather tha n trying to recode your p rograms in a new Ian guage.When faced with this bewilderi ng array of soluti ons to the clie nt-side p rogram ming p roblem, the best plan of attack is a cost-be nefit an alysis. Con sider the con stra ints of your p roblem and what would be the shortest path t
60、o your solution. Since clientside programming is still programming, it' s always a gooto take the fastest development approach for your particular situation. This is an aggressive stanee to prepare for in evitable encoun ters with the p roblems of p rogram devel opment.p rogram mingThis whole discussion
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024年专项烟囱拆除施工协议版
- 雨污分流工程安全施工协议
- 2024年办公楼装修协议范本2篇
- 2024合作事项细化执行协议
- 通信企业文秘招聘协议
- 2024办公楼的租赁协议书
- 2024商业空间装饰设计与施工协议版B版
- 服装公司设计师聘用合同样本
- 独立产权二手房买卖合同模板
- 建筑施工安装分包合同:住宅装修
- 《信条》公开课:2024年电影教学新视角
- Excel+VBA编程入门到精通培训课件(2024年版)
- 四年级数学(上)计算题专项练习及答案
- 北京邮电大学《自然语言处理》2023-2024学年期末试卷
- 部编版五年级语文上册快乐读书吧测试题及答案
- 金广辉全国基层名老中医药专家传承工作室经费使用制度
- 18.2《电功率》- 2024-2025学年人教版初中物理九年级全一册
- 2024年工程居间合同范本格式
- 电力工程起重吊装施工方案
- 2024智慧城市数据字典生活圈部分
- TSG ZF001-2006《安全阀安全技术监察规程》
评论
0/150
提交评论