Applets and Security
Now that you understand how files are transferred across the Web, you’re ready to explore how applets are transferred. On one hand, applets are just more files that are transferred like any other. On the other hand, what an applet can do is closely related to where it came from. This isn’t true of other data types such as HTML and GIF.
Where Do Applets and Classes Come from?
When a web browser
sees an applet tag and decides to download and
play the applet, it starts a long chain of events. Let’s say
your browser sees the following applet tag:
<applet codebase="http://metalab.unc.edu/javafaq/classes"
code="Animation.class" width="200" height="100">The web browser sets aside a rectangular area on the page 200 pixels wide and 100 pixels high. In most web browsers, this area has a fixed size and cannot be modified once created. The
appletviewerin the JDK is a notable exception.The browser opens a connection to the server specified in the
codebaseparameter, using port 80 unless another port is specified in thecodebaseURL. If there’s nocodebaseparameter, then the browser connects to the same server that served the HTML page.The browser requests the
.classfile from the web server as it requests any other file. If acodebaseis present, it is prefixed to the requested filename. Otherwise, the document base (the directory that contains the HTML page) is used. For example:GET /javafaq/classes/Animation.class HTTP 1.0
The server responds by sending a MIME header followed ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access