Sams Teach Yourself Java™ in 24 Hours (Covering Java 7 and Android)

(singke) #1
ptg7068951

246 HOUR 17:Creating Interactive Web Programs


<applet>. There’s also a typeattribute that must be “application/
x-java-applet”, the designated MIME type of Java applets. (MIME types
categorize file formats that can be delivered over the Internet.) Here’s the
start to the formatting of an object:
<objecttype=”application/x-java-applet”height=”300”width=”400”>
</object>

The codeand codebaseof an applet are not designated as attributes.
Instead, parameters named codeand codebaseare placed within the open-
ing <object>tag and closing </object>tag.
The following HTML5markup displays an applet:
<objecttype=”application/x-java-applet”height=”300”width=”400”>
<param name=”code” value=”StripYahtzee” />
<param name=”codebase” value=”javadir” />
<p>Sorry, no dice ... this requires a Java-enabled browser.</p>
</object>

Summary
Most of the hours in this book focus on applications, primarily because
most Java programmers today don’t do a lot of work designing applets for
the Web.
Applets are limited by a set of default security restrictions that make them
safe to be executed on user computers in a web browser. They can’t save
files to the computer, read files from the computer, list file folders, or create
pop-up windows that are not identified as Java applets, among other safe-
guards.
These restrictions can be overcome by signing an applet with a digital sig-
nature and asking a user to approve the applet. An alternative to deploy-
ing Java programs as applets is to use Java Web Start, a technology for
launching Java applications from a web browser.
Free download pdf