phrase, causing the browser to load another page. We explain how this works.
Consider the tag pair:
<a href="http://www.amazon.com">Amazon's page</a>
Parameter href of tag <a> has as argument the URL ( Uniform Resource Locator )
of the page that is to be loaded. Generally, the text between the commands is blue
and underlined, and clicking it loads the page at the given URL. That is all there
is to implementing a hyperlink in a web page!
The applet tag
Here is an example of an applet tag (and its ending partner), which can be
placed in an html page:
<applet code = "Apple.class" width=100 height=200>
your browser will not run this applet! </applet>
Parameter code has as its corresponding argument the name of a .class file
that resides in the same directory as the html page in which the applet tag occurs.
This .clas s file is the compiled version of a .java file that is a subclass of class
Applet (in package java.applet ). In addition, the applet tag has arguments that
give the width and height (in pixels) of the rectangle that will appear in the
browser page. We looked at class applet in Sec. 16.3.
When the browser opens the web page, the Java applet given in file Apple.
class is executed. But not all browsers can run applets. A browser that cannot
will instead display the text that appears between the applet and /applet tags.
If the Java .class files that make up the applet appear in another folder,
even on a different computer, the URL of that folder should be given in a code-
base argument. For example, suppose an IDE places the .class files in a fold-
er named Java Classes . Then, use this applet tag, which uses a URL that is rel-
ative to the folder in which the html file appears:
<applet code = "Apple.class" width=100 height=200
codebase = "Java Classes">
Sorry, this browser does not do applets </applet>
Any URL can be used to give the codebase , even one that refers to a folder
on a different computer.
Specifying a jar file
An applet may consist of many .class files. If this applet is on another
computer, each .class file must be obtained by sending a message to that com-
puter to deliver it. Requesting and retrieving individual files in this manner is rel-
atively time consuming —each could take several seconds or more. To overcome
this problem, jar files were introduced —see Sec. 16.1.
An archive argument is used in an applet tag to specify that a jar file is
available. For example, to indicate that the .class files are in file Apple.jar ,