I am making an applet in Java that will be embedded into a web page, but the URL of the page is dynamic. I need to be able to get the current URL of the page that the applet is running on. Does anyone know how to do this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
See
getDocumentBase()It works fine here. I just tested it using this code.
To compile & run it, do the following after saving the source.
The
.javaextension on the second line is no typo. Recent versions of applet viewer will look in the specified source code for anappletelement defined in a comment.