According to the spec of Applet.getDocumentBase(), this method "Returns an
absolute URL naming the directory of the document in which the applet is
^^^^^^^^^
embedded."
However, the following example shows that the whole URL including HTML file name
is returned:
import java.applet.*;
public class DummyApplet extends Applet {
public void start() {
super.start();
System.out.println("Document Base: " + getDocumentBase());
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body>
<applet
codebase="file:///home/alwang/pp/"
CODE=DummyApplet
WIDTH=500 HEIGHT=400>
</applet>
</body>
</html>
% appletviewer file:///home/alwang/pp/applet.html
The output from AppletViewer is:
Jul 9, 2002 2:23:20 PM java.util.prefs.FileSystemPreferences$3 run
WARNING: Could not create system preferences directory. System preferences are unusable.
Document Base: file:/home/alwang/pp/applet.html
absolute URL naming the directory of the document in which the applet is
^^^^^^^^^
embedded."
However, the following example shows that the whole URL including HTML file name
is returned:
import java.applet.*;
public class DummyApplet extends Applet {
public void start() {
super.start();
System.out.println("Document Base: " + getDocumentBase());
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body>
<applet
codebase="file:///home/alwang/pp/"
CODE=DummyApplet
WIDTH=500 HEIGHT=400>
</applet>
</body>
</html>
% appletviewer file:///home/alwang/pp/applet.html
The output from AppletViewer is:
Jul 9, 2002 2:23:20 PM java.util.prefs.FileSystemPreferences$3 run
WARNING: Could not create system preferences directory. System preferences are unusable.
Document Base: file:/home/alwang/pp/applet.html
- duplicates
-
JDK-4710854 JApplet.getCodeBase() and getDocumentBase() don't work as documented
-
- Closed
-