The class below shows hot to get the host name of an applet.

Java Code:
import java.applet.*;
import java.awt.*;

public class FromWhere extends Applet {
  public void init() {
    Label label = new Label(getCodeBase().toString());

    add(label);
    //
    // you can check the value of getCodeBase()
    // to implements a simple copy protection
    // scheme. If it's not equals to your
    // URL then quit.
    // NOTE : This is not a very strong protection!
    //
  }
}