{\r
if (file.indexOf("://") == -1)\r
{\r
- String fl = applet.getDocumentBase() + file;\r
+ String fl = applet.resolveUrlForLocalOrAbsolute(file, getDocumentBase());\r
try\r
{\r
if (new java.net.URL(fl).openStream() != null)\r
{\r
}\r
;\r
- fl = applet.getCodeBase() + file;\r
+ fl = applet.resolveUrlForLocalOrAbsolute(file, getCodeBase());\r
try\r
{\r
if (new java.net.URL(fl).openStream() != null)\r
{\r
if (debug)\r
{\r
- if (debug)\r
- {\r
- System.err.println("Prepended codebase for resource: '"\r
- + file + "'");\r
- }\r
- return fl;\r
+ System.err.println("Prepended codebase for resource: '"\r
+ + file + "'");\r
}\r
+ return fl;\r
}\r
} catch (Exception x)\r
{\r
showURL(helpUrl, "HELP"); \r
}\r
\r
+ /**\r
+ * form a complete URL given a path to a resource and a reference location on the same server\r
+ * @param url - an absolute path on the same server as localref or a document located relative to localref\r
+ * @param localref - a URL on the same server as url\r
+ * @return a complete URL for the resource located by url\r
+ */\r
+ private String resolveUrlForLocalOrAbsolute(String url, URL localref)\r
+ {\r
+ String codebase = localref.toString();\r
+ if (url.indexOf("/") == 0)\r
+ {\r
+ url = codebase.substring(0, codebase.length()\r
+ - localref.getFile().length())\r
+ + url;\r
+ }\r
+ else\r
+ {\r
+ url = localref + url;\r
+ }\r
+ return url;\r
+ }\r
\r
/**\r
* open a URL in the browser - resolving it according to relative refs and coping with javascript: protocol if necessary.\r
// TODO: verify (Bas Vroling bug) prepend codebase or server URL to\r
// form valid URL\r
// Should really use docbase, not codebase.\r
- URL base = getDefaultParameter("resolvetocodebase", false) ? getDocumentBase() : getCodeBase();\r
- String codebase = base.toString();\r
- if (url.indexOf("/") == 0)\r
- {\r
- url = codebase.substring(0, codebase.length()\r
- - base.getFile().length())\r
- + url;\r
- }\r
- else\r
- {\r
- url = base + url;\r
- }\r
+ URL prepend;\r
+ url = resolveUrlForLocalOrAbsolute(url, prepend=getDefaultParameter("resolvetocodebase", false) ? getDocumentBase() : getCodeBase());\r
if (debug) {\r
- System.err.println("Show url (prepended "+codebase+" - toggle resolvetocodebase if code/docbase resolution is wrong): " + url);\r
+ System.err.println("Show url (prepended "+prepend+" - toggle resolvetocodebase if code/docbase resolution is wrong): " + url);\r
}\r
}\r
else\r