> Thomas schrieb:
> > now, there is page, the link is like this:
> > http://localhost:14654/aes/cTrace/default.aspx.
> > It contains a Java Applet. when I click a button on the Applet, I hope
> > get a url like this: http://localhost:14654/aes/cTrace/.
> > how can I get it?
What exactly do you mean by 'get'?
> Applet.getAppletContext().showDocument(URL) ?
This method will display a new web page (if your lucky),
but is not reliable, and I suspect not what you want..
To get an URL representing the document base, the
address of the web page itself, try..
java.applet.Applet.getDocumentBase()
..you might need to hack that a bit to get the exact information
you are after (e.g. do a String.lastIndexOf("/") to trim the tail end)
HTH
Andrew T.
Simon - 12 Oct 2006 14:24 GMT
Andrew Thompson schrieb:
>> Thomas schrieb:
>>> now, there is page, the link is like this:
[quoted text clipped - 9 lines]
> This method will display a new web page (if your lucky),
> but is not reliable, and I suspect not what you want..
You are probably right. I was not sure what the OP was asking for, hence the
question mark. Probably your answer is the right one. I thought he wanted to
display something because that was supposed to happen after a button was clicked.
Cheers,
Simon
Andrew Thompson - 12 Oct 2006 14:38 GMT
> Andrew Thompson schrieb:
> >> Thomas schrieb:
[quoted text clipped - 3 lines]
> >
> > What exactly do you mean by 'get'?
...
> ...I was not sure what the OP was asking for, ..
I'm still not sure. Perhaps you (Thomas) can explain.
Andrew T.
Simon schrieb:
> Thomas <qixiangnj@gmail.com> schrieb:
>
[quoted text clipped - 5 lines]
>
> Applet.getAppletContext().showDocument(URL) ?
In addition to what Simon and Andrew wrote:
You get the page, which contains the applet, by:
URL docBase = this.getDocumentBase();
// you'll get "http://localhost:14654/aes/cTrace/default.aspx"
You can construct new URLs from it by:
URL url = new URL(docBase, "bla.html");
// you'll get "http://localhost:14654/aes/cTrace/bla.html"
or
URL url = new URL(docBase, ".");
// you'll get "http://localhost:14654/aes/cTrace/"
Finally you can try to show this URL:
this.getAppletContext().showDocument(url);

Signature
Thomas <i.dont.like.spam@invalid.com>
Andrew Thompson - 12 Oct 2006 15:42 GMT
....
> URL docBase = this.getDocumentBase();
> // you'll get "http://localhost:14654/aes/cTrace/default.aspx"
>
> You can construct new URLs from it by:
> URL url = new URL(docBase, "bla.html");
> // you'll get "http://localhost:14654/aes/cTrace/bla.html"
Huhh!
I would not have known that if you had not mentioned it.
I would not have believed it unless I tried it and saw it work.
After revisiting the JavaDocs for that constructor again,
and having become confused by the text within the third
sentence, I *still* do not understand why it works.
It is funky though (and much better than rolling a custom
version using String.indexOf()!).
Andrew T.
Thomas Fritsch - 12 Oct 2006 17:34 GMT
> ....
>
[quoted text clipped - 9 lines]
> I would not have known that if you had not mentioned it.
> I would not have believed it unless I tried it and saw it work.
Andrew, nice to dumbfound you ;-)
> After revisiting the JavaDocs for that constructor again,
> and having become confused by the text within the third
> sentence, I *still* do not understand why it works.
Agreed. The JavaDoc of URL(URL,String) is next to incomprehensible
(caused kind of StackOverflowException in my head).

Signature
Thomas Fritsch
Thomas - 12 Oct 2006 16:10 GMT
thanks, All
I hava solved my problem using the code blew:
URL codeBase = getCodeBase();
......
about the mean of "get", I am sorry for my inattention.
I mean that: I want to get a new URL based by the URL of the Applet.
thanks!
Best Regards,
Thomas
> Simon schrieb:
>
[quoted text clipped - 23 lines]
> Finally you can try to show this URL:
> this.getAppletContext().showDocument(url);