Java Reference
In-Depth Information
Document and Code Base
The document and code bases are important topics in applets because of how
they relate to sandbox security. The document base is the base URL of the
HTML document, and the code base is the base URL of the applet's bytecode.
These do not need to be in the same location; however, security restrictions
force an applet to only use classes that are located at the applet's code base.
For example, suppose a Web page is located at the following URL:
http://www.javalicense.com/jeopardy/index.htm
The document base for the index.htm page is:
http://www.javalicense.com/jeopardy
Suppose that an applet named com.javalicense.JeopardyApplet is embed-
ded in the index.htm page, and the URL of the .class file is
http://www.wiley.com/applets/com/javalicense/JeopardyApplet.class
The code base for this applet is:
http://www.wiley.com/applets
Notice that the /com/javalicense/ portion of the URL is required as part of
the package name and is not a part of the code base. The codebase attribute of
the <applet> tag is used to denote in the HTML file where the applet code can
be found. For example, the index.htm page that embeds the JeopardyApplet
might look similar to the following.
<html>
<head>
<title>Java Jeopardy</title>
</head>
<body>
<h2>Java Jeopardy</h2>
<applet code=”com.javalicense.JeopardyApplet”
width=”400”
height=”450”
codebase=” http://www.wiley.com/applets”
align=”center”
archive=”jeopardy.jar”>
Search WWH ::




Custom Search