⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch3.htm

📁 Java_by_Example,初级经典例子哦,珍藏版本
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<HTML><HEAD><TITLE>developer.com - Reference</TITLE><META NAME="Author" CONTENT="developer.com"><META NAME="Keywords" CONTENT="javascript, ActiveX, VRML, Push, channel,push channel, applet, directory, news, community, developer, internet,intranet, java, java applet, J++, javabeans, java products, tools, javatools, JDK, java development kit, java development environment, JIT,JavaPlan, enterprise tools, JVM, Java Virtual Machine, Java resources, API,browser, java documentation, CDF, Common Desktop Format, RDF, ResourceDescription Framework, Netcaster, Netcast, Castanet, meta-language, metadata,solaris, Solaris, SUN, CGI, Perl, Oracle, database, network, Netscape API,Apache, apache, SSL, mSQL, Netscape, Fasttrack, FastTrack,industry standard, ActiveX bridge, web, internet, site, sitedesign, microsoft, active server pages, asp, iis, nt, win95, 95, html, cgi,frontpage, business, corporate, vbscript, javascript, activex, isapi,database, access, sql, server, www, 3.0, 3.01, 3.02, 3.03, 3.04, 4.0,4.0b2, 4.01, 4.03, 4.04, connection, online, commerce, publisher,publishing, publish, webmaster, dynamic html, dhtml, windows 98, netscape,netscape software, shareware, magazines, jobs, japan, free, freeware, freestuff"><META NAME="description" CONTENT="Developer.com is the leading onlineservice for developers. It includes Gamelan, the official directory for Java, as wellas news, information, tutorials, and directories for other Internet technologiesincluding ActiveX, JavaScript, perl, VRML, Java Beans, push technologies, andother Internet and intranet technologies. Developer.com is also the home ofDeveloper Direct, the Professional Developer's Store, where developers canpurchase and download thousands of Web, authoring and other developmentproducts at some of today's lowest prices."><META NAME="distribution" CONTENT="global"><META NAME="resource-type" CONTENT="document"><META NAME="language" CONTENT="en"></HEAD><BODY BACKGROUND="/images/curve_r-wide.gif" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#DD0000" VLINK="#999999" ALINK="#FF0000"><TABLE><TR><TD VALIGN=TOP WIDTH=120><A HREF="/" ><IMG SRC="/images/masthead_r.gif" WIDTH="100" HEIGHT="78" BORDER="0"ALT="Developer.com Logo"></a></TD><TD><a target="resource window" href="http://adserver.developer.com/cgi-bin/accipiter/adclick.exe/AREA=DCBAN.REF/DT=null"><img src="http://adserver.developer.com/cgi-bin/accipiter/adserver.exe/AREA=DCBAN.REF/DT=null" HEIGHT="60" WIDTH="468" ALT="Click here to support our advertisers"><BR><CENTER>Click here to support our advertisers</CENTER></a></TD></TR></TABLE><!--outer table--><TABLE><!--outer table--><TR><!--outer table--><TD VALIGN="TOP"><!--navbar info --><table><tr><td><A HREF="http://www.developerdirect.com/" ><IMG SRC="/images/button_s.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><b>SHOPPING</b></font></a></td></tr><tr><td><A HREF="/community/jobs/c_jobs.html"><IMG SRC="/images/button_d.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><B>JOB BANK</B></font></a></td></tr><tr><td><A HREF="http://www.classifieds2000.com/cgi-cls/display.exe?Developer+computer+searchcomputercategories"><IMG SRC="/images/button_d.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><B>CLASSIFIEDS</B></font></a></td></tr><tr><td><A HREF="/directories/directories.html"><IMG SRC="/images/button_d.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><B>DIRECTORIES</B></font></a></td></tr><tr><td><A HREF="/reference/"><IMG SRC="/images/button_r.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><B>REFERENCE</B></font></a><br><a href="/reference/r_library.html"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000">Online Library</a></font></td></tr><tr><td><A HREF="/classroom/"><IMG SRC="/images/button_r.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><B>LEARNING CENTER</B></font></a></td></tr><tr><td><A HREF="/journal/"><IMG SRC="/images/button_n.gif" width="15" height="11" BORDER="0"><B><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000">JOURNAL</font></B></a></td></tr><tr><td><A HREF="/news/"><IMG SRC="/images/button_d.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><b>NEWS CENTRAL</b></font></a></td></tr><tr><td><A HREF="/downloads/"><IMG SRC="/images/button_d.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><b>DOWNLOADS</b></font></a></td></tr><tr><td><A HREF="/community/" ><IMG SRC="/images/button_c.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><B>COMMUNITY</B></font></a></td></tr><tr><td><A HREF="/calendar/"><IMG SRC="/images/button_d.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><b>CALENDAR</b></font></a></td></tr><tr><td><A HREF="/about/"><IMG SRC="/images/button_a.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><b>ABOUT US</b></a></font></td></tr></table><table><tr><td><form action="/subscribe/list.cgi" method=post ><img src="/images/rule.gif" width="100" height="2"><br><B><FONT FACE="Arial, Helvetica" SIZE="-1">Journal:</b></font><br><input name='email' value='your e-mail' size="11"><input type='hidden'  name='state' value='Subscribe'></td></tr><tr><td><input type='submit' value='Subscribe'><br><font size="-1">Get the weekly email highlights from the most popular journal for developers!<br><a href="http://www.developer.com/subscribe.html">Current issue</a><img src="/images/rule.gif" width="100" height="2"><input type='hidden' name='name' value='New Subscriber'></FORM></td></tr></table><!--/navbar--><font size="-1"><A HREF="http://www.developer.com">developer.com</a><BR><A HREF="http://www.developerdirect.com">developerdirect.com</a><BR><A HREF="http://www.htmlgoodies.com">htmlgoodies.com</a><BR><A HREF="http://www.javagoodies.com">javagoodies.com</a><br><A HREF="http://www.jars.com">jars.com</a><BR><a href="http://www.intranetjournal.com">intranetjournal.com</a><br><a href="http://www.javascripts.com">javascripts.com</a><br></font><!--outer table--></TD><!--outer table--><TD VALIGN="TOP"><BLOCKQUOTE><P><img src="/images/header_r.gif" width="440" height="50"><P><MAP NAME ="header_r2.gif.map"><AREA SHAPE ="RECT"      HREF ="/reference/author.html"      COORDS ="361,0,440,29"><AREA SHAPE ="RECT"      HREF ="/reference/basic.html"      COORDS ="254,0,360,29"><AREA SHAPE ="RECT"      HREF ="/reference/help.html"      COORDS ="183,0,251,29"><AREA SHAPE ="RECT"      HREF ="/reference/cool.html"      COORDS ="100,0,181,29"><AREA SHAPE ="RECT"      HREF ="/reference/mybook.html"      COORDS ="0,0,100,29"></MAP><MAP NAME ="header_r1.gif.map"><AREA SHAPE ="RECT"      HREF ="/reference/personalize.html"      COORDS ="339,0,439,29"></MAP><p><font face="Arial,Helvetica" size="-1" color="#006666"><A HREF="/reference/r_library.html"><B>All Categories</A> :</B><b><A HREF="/reference/r_java.html">Java</A></b></font><p><META><H1><FONT SIZE=6 COLOR=#Ff0000>Chapter&nbsp;3</FONT></H1><H1><FONT SIZE=6 COLOR=#Ff0000>Applets and the Internet</FONT></H1><HR><P><CENTER><B><FONT SIZE=5><A NAME="CONTENTS">CONTENTS</A></FONT></B></CENTER><UL><LI><A HREF="#LocalandRemoteApplets">Local and Remote Applets</A><UL><LI><A HREF="#LocalApplets">Local Applets</A><LI><A HREF="#RemoteApplets">Remote Applets</A></UL><LI><A HREF="#ClientsandServers">Clients and Servers</A><LI><A HREF="#Security">Security</A><LI><A HREF="#ExampleYourPagesontheWeb">Example: Your Pages on the Web</A><LI><A HREF="#Summary">Summary</A><LI><A HREF="#ReviewQuestions">Review Questions</A><LI><A HREF="#ReviewExercises">Review Exercises</A></UL><HR><P>Now that you have some idea how you can add Java applets to yourWeb pages, you need to discover how applets are handled on theInternet. After all, it is an applet's ability to hitch a rideon the Information Superhighway that makes it so unique. In fact,applets are really the first step towards making the Interneta true extension of your computer's local storage system. Whenyou view a Web page containing applets, those applets may be comingto you from just about anywhere on the Web-from the office downthe street or from a software distributor in Hong Kong. In thischapter, you discover just how this interaction works.<H2><A NAME="LocalandRemoteApplets"><FONT SIZE=5 COLOR=#Ff0000>Local and Remote Applets</FONT></A></H2><P>One of Java's major strengths is that you can use the languageto create dynamic content for your Web pages. That is, thanksto Java applets, your Web pages are no longer limited to the tricksyou can perform with HTML. Now your Web pages can do just aboutanything you want them to. All you need to do is write the appropriateapplets.<P>But writing Java applets is only half the story. How your Webpage's users obtain and run the applets is equally as important.It's up to you to not only write the applet (or use someone else'sapplet), but also to provide users access to the applet. Basically,your Web pages can contain two types of applets: local and remote.In this section, you learn the difference between these applettypes, which are named after the location at which they are stored.<H3><A NAME="LocalApplets">Local Applets</A></H3><P>A local applet is one that is stored on your own computer system(Figure 3.1). When your Web page must find a local applet, itdoesn't need to retrieve information from the Internet-in fact,your browser doesn't even need to be connected to the Internetat that time. As you can see in Listing 3.1, a local applet isspecified by a path name and a file name.<P><A HREF="f3-1.gif"><B> Figure 3.1 : </B><I>Local applets are stored on and loaded from your computer system.</I></A><P><HR><BLOCKQUOTE><B>Listing 3.1&nbsp;&nbsp;LST3_1.TXT: Specifying a Local Applet.<BR></B></BLOCKQUOTE><BLOCKQUOTE><PRE>&lt;applet    codebase=&quot;tictactoe&quot;    code=&quot;TicTacToe.class&quot;    width=120    height=120&gt;&lt;/applet&gt;</PRE></BLOCKQUOTE><HR><P>In Listing 3.1, the <TT>codebase</TT> attribute specifies a pathname on your system for the local applet, whereas the <TT>code</TT>attribute specifies the name of the byte-code file that containsthe applet's code. The path specified in the <TT>codebase</TT>attribute is relative to the folder containing the HTML documentthat references the applet. (See the &quot;Optional Attributesfor Applets&quot; section of <A HREF="ch2.htm" >Chapter 2</A>for more information.)<H3><A NAME="RemoteApplets">Remote Applets</A></H3><P>A remote applet is one that is located on another computer system(Figure 3.2). This computer system may be located in the buildingnext door or it may be on the other side of the world-it makesno difference to your Java-compatible browser. No matter wherethe remote applet is located, it's downloaded onto your computervia the Internet. Your browser must, of course, be connected tothe Internet at the time it needs to display the remote applet.<P><A HREF="f3-2.gif"><B> Figure 3.2 : </B><I>Remote applets are stored on another system and are down-loaded onto your computer via the Internet.</I></A><P><P>To reference a remote applet in your Web page, you must know theapplet's URL (where it's located on the Web) and any attributesand parameters that you need to supply in order to display theapplet correctly. If you didn't write the applet, you'll needto find the document that describes the applet's attributes andparameters. This document is usually written by the applet's author.Listing 3.2 shows how to compose an HTML <TT>&lt;applet&gt;</TT>tag that accesses a remote applet.<HR><BLOCKQUOTE><B>Listing 3.2&nbsp;&nbsp;LST3_2.TXT: Specifiying a Remote Applet.<BR></B></BLOCKQUOTE><BLOCKQUOTE><PRE>&lt;applet    codebase=&quot;http://www.myconnect.com/applets/&quot;    code=&quot;TicTacToe.class&quot;    width=120    height=120&gt;&lt;/applet&gt;</PRE></BLOCKQUOTE><HR><P>The only difference between Listing 3.1 and Listing 3.2 is thevalue of the <TT>codebase</TT> attribute. In the first case, <TT>codebase</TT>specifies a local folder, and in the second case, it specifiesthe URL at which the applet is located.<H2><A NAME="ClientsandServers"><FONT SIZE=5 COLOR=#Ff0000>Clients and Servers</FONT></A></H2>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -