Brief Introduction
Java is a general-purpose object-orientated platform-independent programming language. As a programming language, it provides industrial-strength capabilities to create fully interactive, dynamic applications. As it is platform-independent, programs created in Java can run on virtually any computer, regardless of the operating system or architecture. Java programs are compiled into bytecode that is executable by a Java virtual machine. Any system that has an implementation of the Java virtual machine can run the same compiled bytecode. Javas platform-independence is what makes it ideally suited for the Internet. Special Java bytecode files, called applets, can be distributed over the network without concern for different user platforms. By embedding Java applets in WWW documents, you can deliver dynamic, interactive content from within your Web pages. The Java applet is downloaded with the HTML and executed locally on the users computer. The user can continue to interact with the Java applet without ongoing contact with the HTTP server.
The OBJECT element
To embed Applets in HTML pages the tags <OBJECT> and </OBJECT> are used. In general, none of the attributes for OBJECT are required. For use as a container for an applet, however, either classid or data is required; width, height, and either codetype or type is recommended. OBJECT is an all-purpose element for generic object inclusion. Applets are just one kind of object that can be included with it.
Attributes
The attributes associated with the embedded object are as follows:
When present, this boolean attribute makes the current OBJECT definition a declaration only.
This attribute may be used to specify the location of the objects implementation via a URL, i.e., the location of the applet.
This attribute specifies the base path used to resolve relative URLs specified by the classid, data, and archive attributes. When absent, its default value is the base URL of the current document.
This attribute may be used to specify the location of the objects data, e.g., a serialized representation of the applet.
This attribute specifies the content type for the data specified by data. This attribute is optional but recommended when data is specified since it allows the browser to avoid loading information for unsupported content types.
This attribute specifies the content type of the object specified by classid. For Java applets, this should be "application/java". This attribute is optional but recommended when classid is specified since it allows the browser to avoid loading information for unsupported content types. When absent, it defaults to the value of the type attribute.
This attribute may be used to specify a space-separated list of URLs for archives containing resources relevant to the object. Preloading archives will generally result in reduced load times for objects. Archives specified as relative URLs should be interpreted relative to the codebase attribute.
This attribute specifies a message that the browser may render while loading the objects implementation and data.
This attribute is used to tell browsers to override the natural object height in favour of this value.
This attribute is used to tell browsers to override the natural object width in favour of this value.
This attribute associates an image map with the object. This is not generally of use when the object is an applet.
This attribute assigns the object name.
This attribute specifies the position of the current object in the tabbing order for the current document. This value must be a number between 0 and 32767. Browsers should ignore leading zeros.
Example
In practice, the following HTML code would suffice for a standard embedded JAVA applet:
<OBJECT codetype="application/java" classid="java:HelloWorldApplet.class" width="200" height="40"> Java applet that prints a message. </OBJECT>
An Example of the code for a very basic JAVA Applet is shown here:
import java.awt.*; import java.applet.*; public class HelloWorldApplet extends Applet { public void paint(Graphics g) { g.drawString("Hello World!", 20, 20); } }
To view this Example click Here
© Nigel Martin 2000 ma71nm@surrey.ac.uk Created September 2000 Last Changed April 13, 2001