-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
pp_1.0, 1.4.0, 1.4.1
-
x86, sparc
-
solaris_7, windows_2000
Name: gm110360 Date: 07/03/2002
FULL PRODUCT VERSION :
java version "1.4.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)
FULL OPERATING SYSTEM VERSION : Win2kPro, all updates
EXTRA RELEVANT SYSTEM CONFIGURATION :
Latest docs and JDK
A DESCRIPTION OF THE PROBLEM :
getDocumentBase() returns an URL to the html file in which
the applet is embeded, not the parent dir of the html file.
Docs read-
getDocumentBase
public URL getDocumentBase()
Returns an absolute URL naming the directory of the
document in which the applet is embedded. For example,
suppose an applet is contained within the document:
http://java.sun.com/products/jdk/1.2/index.html
The document base is:
http://java.sun.com/products/jdk/1.2/
Returns-
the URL of the document that contains this applet.
see getCodeBase() also.
*********************************************************
getCodeBase() returns the parent of the html file the applet
is embedded in, not the URL of the applet itself.
Docs read:
public URL getCodeBase()
Gets the base URL. This is the URL of the applet itself.
Returns:
the URL of this applet.
See getDocumentBase() also
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.) make and applet, Mine just had:
public void init()
{
docBase = this.getDocumentBase();
codeBase = this.getCodeBase();
}
public void paint(Graphics g)
{
g.drawString(docBase.toString(), 25, 50);
g.drawString(codeBase.toString(), 25, 100);
}
2.) Make an html file with an <applet tag>
3.) Request it.
EXPECTED VERSUS ACTUAL BEHAVIOR :
expect: url to directory html file is in
expect: the url of the applet itself
actual: url to the html file
actual: url to the directory of the html file
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package chapter4;
import java.net.*;
import java.io.*;
import javax.swing.*;
import java.awt.*;
public class JTMSplitPane extends JApplet
{
URL docBase;
URL codeBase;
public void init()
{
docBase = this.getDocumentBase();
codeBase = this.getCodeBase();
}
public void paint(Graphics g)
{
g.drawString(docBase.toString(), 25, 50);
g.drawString(codeBase.toString(), 25, 100);
}
}
***************************************************************************
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>chapter4.JTMSplitPane</title></head><body>
<Applet code=chapter4.JTMSplitPane width=400 height=300></Applet>
</body></html>
---------- END SOURCE ----------
(Review ID: 153868)
======================================================================
- duplicates
-
JDK-4712311 getDocumentBase() returns the URL including file name
-
- Closed
-
-
JDK-4816483 getDocumentBase() in applet package is broken
-
- Closed
-
-
JDK-4456393 (api) getDocumentBase and getCodeBase do each other's jobs.
-
- Resolved
-