Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7769751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:14:08+00:00 2026-06-01T16:14:08+00:00

I am making an applet in Java that will be embedded into a web

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T16:14:10+00:00Added an answer on June 1, 2026 at 4:14 pm

    See getDocumentBase()


    Using getDocumentBase() actually gave me a NullPointerException..

    It works fine here. I just tested it using this code.

    // <applet code=MyLocation width=400 height=30></applet>
    import javax.swing.*;
    
    public class MyLocation extends JApplet {
    
        @Override
        public void init() {
            add( new JLabel(getDocumentBase().toString()));
        }
    }
    

    To compile & run it, do the following after saving the source.

    prompt> javac MyLocation.java
    prompt> appletviewer MyLocation.java
    

    The .java extension on the second line is no typo. Recent versions of applet viewer will look in the specified source code for an applet element defined in a comment.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Theres a web page I'm making which content is very dynamic and so I'm
I am in the process of turning my java application into a web applet.
I have a Java Applet that I'm making some edits to and am running
We have a web applet that loads under the URL https://secure-ausomxeja.crmondemand.com/OnDemand/ ... from where
I am making a Java application that is stored in a .jar file and
I'm making a TCP Client in Applet mode and I get this strange error...
I'm making an applet consisting of a ball that moves across the screen. I
I need to open an external window from a Java applet. How can I
I'm making an applet that lets users crop out a piece of an image
I'm making a game in a java applet and I'm trying to optimise my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.