(Apple bug report # 2712777, Bugzilla bug # 108054 (click link to see or vote for the bug))
This describes problems using showDocument to display a local HTML file on the Macintosh. The problem only occurs when an applet runs from the server and tries to open a local html file. Different problems occur on different versions of Macintosh browsers, and these will be described separately. The Mac OS X / Netscape problem is now fixed.
Macintosh OS 9 / Internet Explorer 5.0:
On OS 9, the problem occurs using Internet Explorer 5.0 but does not occur with Netscape 4.75 (with applet tags) and Netscape 6.01.
There have been disagreements on Java-Dev as to whether
this is correct behavior or a bug and many urged me to file a bug report to get
this cleared up properly. The code and working applet are displayed below.
The crucial line of code is:
new URL("file:///Nine/System Folder/Preferences/SomeFolder/");
The applet,
running from the segal.org server, is meant to direct the browser to open a
local HTML file:
file:///Nine/System%20folder/Preferences/SomeFolder/file.html
but instead the browser tries to open an HTML file on the server:
http://segal.org/Nine/System%20folder/Preferences/SomeFolder/file.html
(OS 9.1; MRJ 2.2.5 and Internet Explorer 5.0). Replacing the one-argument URL constructor:
new URL("file:///Nine/System
Folder/Preferences/SomeFolder/");
with a three-argument URL constructor:
new URL("file", "", "///Nine/System Folder/Preferences/SomeFolder/");
fixes the problem. Other numbers of slashes in the third argument before
"Nine/System..." do not work. Here are the results for different
numbers of slashes:
Macintosh OS 10.1 / Netscape 6.2 with Java Plugin 1.0d5:
This applet crashes Netscape 6.2 with Java Plugin 1.0d5 and is fixed as of 1.0d6. Nothing happens with Internet Explorer 5.1.2.
The applet is in the box below but nothing is displayed in the box. The applet only:
If you have any insights, workarounds or comments about this test page please contact Mickey Segal. A listing of many Macintosh Java bugs with demonstration applets is at this link, including information on how to add any necessary Java plugins.
The code is displayed below and also available from this link.
import java.applet.*;
import java.awt.*;
import java.net.*;
public class ShowDoc extends Applet {
public void init()
{
try
{
URL rootURL = new URL("file:///Nine/System Folder/Preferences/SomeFolder/");
URL url = new URL(rootURL, "file.html");
getAppletContext().showDocument(url, "_blank");
System.out.println("rootURL = " + rootURL);
System.out.println("url = " + url);
}
catch (Exception e)
{
System.out.println(e);
}
}
} // END OF Class ShowDoc