Basics of Applet tag

Below is an example of the simplest Applet tag.
<APPLET
  CODE="SomeApplet.class" 
  HEIGHT="anInteger" 
  WIDTH="anInteger" 
>
<PARAM NAME="paramName1" VALUE="it's value">
<PARAM NAME="paramName2" VALUE="it's value">
<PARAM NAME="paramName3" VALUE="it's value">
<PARAM NAME="paramName4" VALUE="it's value">
Some HTML code can be placed here for 
Java disabled browsers
</APPLET>
What can we find in this example? First of all, we see CODE="SomeApplet.class". This is an actual class filename. Replace this one with the name of applet you want to use, note that Java won't allow you to rename classes, information about classes also stored inside class file, so on attempt to rename class file one will get classNotFound Exception
Be careful, Java is case sensitive, so converting to lowercase while uploading to server is the most frequent reason for this exception.

WIDTH and HEIGHT are an integer values (for example, "100") indicates the applet sizes in pixels. Netscape Navigator accepts a percentage value too (for example, "25%"), but this can cause problems with Microsoft Internet Explorer. So I wouldn't recommend use of percentage values. Another reason why many applets won't work correctly if you use percentage values is that initialization of applet occurs only once after loading, and if the applet gets its sizes in init() method, then it won't get new sizes after you resize the browser window.

You can use PARAM tags between the <APPLET> and </APPLET> tags to provide information about parameters, or arguments, to be used by the Java applet. Each applet has its own set of parameters, you can find the list of parameters in the applet documentation or on the applet example pages. Note that parameters are also case sensitive, so use the parameter names exactly as it's documented. Wrong parameter names or values are often the reason for NullPointerException or IllegalArgumentException. But sometimes, omitted or invalid parameters can cause more exotic exceptions like "Array OutOfBondsException" or something else.

Some particular HTML code can be placed between <applet> </applet>, outside of parameters tag, of course. This portion of HTML will be shown in non java or Java disabled browser. Something like this:

<APPLET CODE="SomeApplet.Class"  HEIGHT="100" WIDTH="200">
<PARAM NAME="paramName1" VALUE="it's value">
<PARAM NAME="paramNameN" VALUE="it's value">
<B><I>Your browser dosn't support Java</I></B>
</APPLET>

Full syntax of APPLET tag

Full example of applet tag includes many other attributes.
<APPLET
  CODE="classFileName" 
  CODEBASE="classFileDirectory" 
  ARCHIVE="archiveFile" 
  ALT="altText"
  ALIGN="LEFT"|"RIGHT"|"TOP"|"ABSMIDDLE"|"ABSBOTTOM"|
        "TEXTTOP"|"MIDDLE"|"BASELINE"|"BOTTOM"
  HEIGHT="height" 
  WIDTH="width" 
  HSPACE="horizMargin" 
  VSPACE="vertMargin" 
  MAYSCRIPT 
  NAME="value" 
>
<PARAM ...>
<PARAM ...>
</APPLET>
The most important part is CODEBASE, this is the directory containing the applet class file. It can be in an absolute or a relative form. In the case of relative CODEBASE, it is relative to the document's base URL defined by the document BASE tag. If the document does not define a BASE tag, it is relative to the HTML document directory. At least this is stated in Netscape Navigator HTML references, but... For my experience omitted CODEBASE or codebase in relative form is a frequent reason for SecurityExceptions in NN4.x. Looks like security manager does not get default codebase value from document location, so Java paranoiac security disables access to images or other resources the applet needs. As a result, the applet can't obtain images or sounds or other files from server. The only work around I found, is to specify the codebase in full URL form for applets which requires connection to server in order to obtain images or other files. In this case if the applet has the files' URLs as parameters, the best solution is to specify its values again as full URLs, to avoid problems with internal applet realization. Two methods can be used to create an URL inside applets from a relative URL. The URL can be built in the context of the document base and in the context of the codebase. As you never can be sure how this may be done in a third party applet, this can cause problems with the Java security manager. In case the document base and codebase are slightly different, the security manager will allow connection only to resources located at codebase, and disallow access to files located on document base. If the applet internally uses the document base to build URLs for files, it wouldn't be able to get these files. You will never have these problems if you use full URLs, but you should be careful, server name in both codebase and resource URL should be the same, and keep in mind case sensitivity.

ARCHIVE="archiveFile" (quote from Netscape documentation)
is a URL for a file in the CODEBASE directory to be downloaded to the user's disk. The suffix on the archive file must be .zip, but the file must not be compressed. The browser searches the archive file for the class file named in the CODE attribute. If the browser cannot find that class file in the archive file, it searches for it using the standard mechanism.Navigator 3.0
Looks like a very useful thing. Some applets are supposed to use more classes located in sub directories. But some web hosting servers (such as Geocities) do not allow you to have sub directories, so one can try to pack directories in the zip file. Main applet class should be located in the root of this archive and then sub directories structure should be the same as the applet requires for its normal operation.
But...(quote from Sun's JDK tutorial) 
The standard Java archive format, called JAR, was introduced in JDK 1.1 and is based on the ZIP file format.
You specify JAR files using the ARCHIVE attribute of the <APPLET> tag. You can specify multiple archive files by separating them with commas.
.....

Unfortunately, not all browsers understand the same archive format or use the same HTML code to specify the
 applet archive. Watch this page for the latest information about browser support for archives. To learn how to
 create a JAR file, see Platform-specific Details: Creating a JAR File.

So what do we actually have? NN3 requires .zip file, NN4 accepts .jar Java1.1 MicrosoftInternetExplorer as usual chooses its own way (cabs). All this makes this nice feature hardly useful at this point in time. I hope this crazy world will turn away from concurrent disagreement to cooperation.

The rest of the parameters are clear and similar to IMG tag attributes, so the last thing to be explained is MAYSCRIPT attribute. Using Netscape's JSObject package applet can call JavaScript methods. (Not supported in MIE3) This attribute permits the applet to access JavaScript. This is a rarely used option. It's much easier to call applet methods from JavaScript, rather than use this package. Meanwhile, this is the only way to save some data from unsigned applet. Data can be stored in a cookie file using this package. Some applets can use this feature, but in most cases this attribute isn't required.

More detailed description of APPLET and PARAM tags available at
http://developer.netscape.com in HTML references and in Sun's  JDK tutorial at http://java.sun.com

by Virtual_Max (http://www.oocities.org/siliconvalley/lakes/8620)