Using OBJECT, EMBED and APPLET Tags in Java Plug-in
This chapter includes the following topics:
"Java Plug-in in Internet Explorer on Microsoft Windows Platforms"
"Java Plug-in in Internet Explorer and Netscape Navigator Browsers"
Introduction
This document explains the tagging structure, involving OBJECT and EMBED tags, required by Java Plug-in. It is intended for web authors who want to manually insert Java Plug-in tags in their HTML pages.
Note - There is a Java Plug-in HTML Converter, available free-of-charge from Sun Microsystems, that automatically does this for you. It is highly recommended that most web authors use it.
Applets are normally specified in an HTML file as follows:
<APPLET code="XYZApp.class" codebase="html/" align="baseline" width="200" height="200"> <PARAM name="model" value="models/HyaluronicAcid.xyz"> No Java 2 SDK, Standard Edition v 1.4 support for APPLET!! </APPLET> |
However, an APPLET is rendered by the browser and there is no easy way to intercept the browser and force it to use Sun's Java Runtime Environment (JRE) to run the applet. To force the browser to do so, however, you may use a special Java Plug-in tagging structure involving the OBJECT or EMBED tag or both, as described below, in place of the usual APPLET tag in your HTML pages. This will cause the browser to launch Java Plug-in, which will then run the applet using Sun's JRE.
For various combinations of browsers and platforms, the following sections tell you exactly what you need to do.
Note - Product version numbers are of the form
n1.n2.n3_n4n5 |
The version numbers used in the examples below refer to the 1.4 major release with minor release number of 0 and, at times, hypothetical update number.
At times you will see modified usages such as 1,4,0,nm and 14 (the latter to indicate only the major version number).
Java Plug-in in Internet Explorer on Microsoft Windows Platforms
To use Java Plug-in with Internet Explorer on Microsoft Windows platforms, use the OBJECT tag. The following is an example of mapping an APPLET tag to a Java Plug-in tag:
Original APPLET Tag
<APPLET code="XYZApp.class" codebase="html/" align="baseline" width="200" height="200"> <PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz"> No Java 2 SDK, Standard Edition v 1.4 support for APPLET!! </APPLET> |
Note - The URL given in the codebase attribute in this and following examples is for illustrative purposes only. No cab file actually exists at that URL.
New OBJECT Tag
<OBJECT classid="clsid:CAFEEFAC-0014-0000-0000-ABCDEFFEDCBA" width="200" height="200" align="baseline" codebase="http://java.sun.com/jpi/jinstall-14-win32.cab#Version=1,4,0,mn"> <PARAM NAME="code" VALUE="XYZApp.class"> <PARAM NAME="codebase" VALUE="html/"> <PARAM NAME="type" VALUE="application/x-java-applet;jpi-version=1.4"> <PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz"> <PARAM NAME="scriptable" VALUE="true"> No Java 2 SDK, Standard Edition v 1.4 support for APPLET!! </OBJECT> |
Note that the OBJECT tag contains similar information to the APPLET tag. It is sufficient to launch Java Plug-in in Internet Explorer. The classid in the OBJECT tag is the class identifier for Java Plug-in itself. This class identifier should be the same in every HTML page. When Internet Explorer renders this class identifier in the OBJECT tag, it will try to load Java Plug-in into the browser.
There are several attributes in the OBJECT tag, such as width, height and align, that are mapped directly from the corresponding attributes in the APPLET tag. These contain formatting information that Internet Explorer will use to position Java Plug-in. Since this information is mapped directly without changes, the position and appearance of the applets using Java Plug-in should be the same as those applets using the APPLET tag.
Not all attributes in the APPLET tag can be mapped to the OBJECT tag attributes. For example, the attributes code and codebase in the APPLET tag are not mapped into the OBJECT tag attribute. Instead, the attribute code is mapped into the PARAM code because, according to the HTML specification, the attribute code does not exist in the OBJECT tag. There are other attributes that do not correspond in the OBJECT tag attributes. These attributes, with one exception, should be mapped to PARAM tags.
Note - Duplicate parameter names should never be used with the OBJECT tag.
The one exception is the codebase attribute. In the APPLET tag, the codebase attribute represents the location from which to download additional class and jar files. However, in the OBJECT tag, the codebase attribute represents the location from which to download Java Plug-in when it is not found on the local machine. Because the codebase attribute has two different meanings in the APPLET and OBJECT tags, you must resolve this conflict by mapping this attribute into a PARAM codebase in the OBJECT tag.
In the above example, the code and codebase attributes in the APPLET tag are mapped into the OBJECT tag parameters. The PARAM code identifies the applet, and its value should be the same as the code attribute in the APPLET tag. The PARAM codebase identifies the codebase of the applet. Java Plug-in knows where to download the applet because it can read this information from the parameters. The parameter type is not mapped from the APPLET tag, but it is required in the OBJECT tag. It identifies the type of the Java executable, such as an applet, so Java Plug-in knows how to initialize the Java executable. These three PARAM tags (code, codebase, and type) in the above example are specified by Java Plug-in. They do not exist in the PARAM of the original APPLET tag. Note that the model parameter within the OBJECT tag is identical to the model parameter inside the APPLET tag. Except for these first three parameters specified for Java Plug-in, the remainder of the parameters are the same as those inside the APPLET tag.
A new addition for Java Plug-in 1.3 (and valid in 1.4) was the PARAM scriptable tag. This was added to improve performance of applets that do not require the use of JavaScript or VBScript. The value should be true if the applet requires scripting support and false if it does not. The value is false by default.
Please note that PARAM scriptable is not the same as the PARAM Mayscript. Mayscript provides support for communication from Java applets to JavaScript only, while scriptable allows communication from JavaScript to Java applets in Internet Explorer only.
The text "No Java 2 SDK, Standard Edition v 1.4 support for APPLET!!" in the APPLET tag is mapped inside the <OBJECT> and </OBJECT>tags. Originally, this text is displayed only if the browser does not have Java support. By mapping it inside the OBJECT tag, this text will displayed if the browser does not support the OBJECT tag.
The APPLET-OBJECT tag attributes mapping is as follows:
Attributes | APPLET tag support | OBJECT tag support | Attribute map in OBJECT tag |
---|---|---|---|
ALIGN | X | X | Attribute ALIGN |
ALT | X |
|
|
ARCHIVE | X |
| Param archive |
CODE | X | X | Param code |
CODEBASE | X | X | Param codebase |
HEIGHT | X | X | Attribute HEIGHT |
HSPACE | X | X | Attribute HSPACE |
NAME | X | X | Attribute NAME, Param NAME |
OBJECT | X |
| Param object |
TITLE | X | X | Attribute TITLE |
VSPACE | X | X | Attribute VSPACE |
WIDTH | X | X | Attribute WIDTH |
MAYSCRIPT | X | X | Param MAYSCRIPT |
Some attributes are special to the OBJECT tag. These attributes are:
Attribute/Param | Meaning in OBJECT tag |
---|---|
Attribute classid | It should always have the same value for dynamic version support, i.e. clsid:8AD9C840-044E-11D1-B3E9-00805F499D93. For static version support it will have a unique value for the version, e.g., clsid:CAFEEFAC-0014-0000-0000-ABCDEFFEDCBA. Note: The examples in this section use the dynamic version. |
Attribute CODEBASE | It should be a full URL pointing to a CAB file somewhere on the network. It should, be default, point to the binary on the Java Software web site. |
Param type | If it is a Java applet, the value should be "application/x-java-applet;jpi-version=1.4" or "application/x-java-applet". If it is a JavaBeans component, the value should be "application/x-java-bean;jpi-version=1.4" or "application/x-java-bean". |
Param codebase | Specifies the base URL of the applet. This attribute is optional. |
Param code | Specifies the name of the Java applet or JavaBeans component. It cannot be used the param object inside the same OBJECT tag. |
Para scriptable | Specifies whether the applet is scriptable from the HTML page using JavaScript or VBScript. The value can be either true or false. This attribute is new in Java Plug-in 1.4. |
Param object | Specifies the name of the serialized Java applet or JavaBeans component. It cannot be used with param code inside the same OBJECT tag. This attribute is optional. |
Param archive | Specifies the name of the Java archive. This attribute is optional. |
Param mayscript | Specifies whether the applet is allowed to access netscape.javascript.JSObject. The value can be either true or false. This attribute is optional. |
Note that if the original APPLET tag has PARAM type, codebase, code, object or archive, mapping it to the OBJECT tag will cause a problem because duplicate param names will occur. To avoid this, Java Plug-in also supports another set of param names, as follows:
Original Param Names | New Param Names |
---|---|
code | java_code |
codebase | java_codebase |
archive | java_archive |
object | java_object |
type | java_type |
You should use these new param names only when necessary. If both the new and original param names exist in the same OBJECT tag, the value associated with the new param name is always used by Java Plug-in to load the applet or JavaBean.