From 932d6a581a349031e6b5f3042d5e62b31b72288f Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Thu, 14 Nov 2002 11:40:19 +0000 Subject: [PATCH] #105128# Applet.getDocumentBase returned the URL of the document and not its directory --- sj2/stardiv/applet/Document.java | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/sj2/stardiv/applet/Document.java b/sj2/stardiv/applet/Document.java index 7264a5420c80..1d3b4d5c174c 100644 --- a/sj2/stardiv/applet/Document.java +++ b/sj2/stardiv/applet/Document.java @@ -2,9 +2,9 @@ * * $RCSfile: Document.java,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 16:54:03 $ + * last change: $Author: jl $ $Date: 2002-11-14 12:40:19 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -89,7 +89,22 @@ class Document implements LiveConnectable { private java.awt.Toolkit toolkit; Document(URL url, java.awt.Toolkit toolkit) { - documentBase = url; + // Create the document base. + //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/ + + String s= url.toString(); + int index= s.lastIndexOf('/'); + if( index != -1) + { + s=s.substring(0, index + 1); + } + try{ + documentBase = new URL(s); + }catch(Exception e){ + } this.toolkit = toolkit; }