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?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
It should work like this:
This method returns you the URL object. Then you obtain what you need :)
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
.java
extension on the second line is no typo. Recent versions of applet viewer will look in the specified source code for anapplet
element defined in a comment.