Example #1
0
  public void init() {
    is_master = false;
    dyn_usr = 0;
    dyn_view = 0;
    id = (int) System.currentTimeMillis();

    ClientApplet.client_applet = this;

    appletContext = getAppletContext();

    hostsrv = getParameter("HOSTSRV");

    String http_portString = getParameter("HTTP_PORT");
    if (http_portString != null) {
      try {
        Integer port = Integer.valueOf(http_portString);
        http_port = port.intValue();
      } catch (NumberFormatException e) {
        http_port = 50000;
      }
    }

    URL applet_url = this.getCodeBase();

    String host = applet_url.getHost();
    if (host != null) hostsrv = host;

    int port = applet_url.getPort();
    if (port > 0) http_port = port;

    user_interface = new UserInterface();
    user_interface.init();
  }
Example #2
0
 /**
  * ** Gets the 'port' specification in the URI ** @return The 'port' specification in the URL, or
  * -1 if not port is specified
  */
 public int getPort() {
   try {
     URL url = new URL(this.getURI());
     return url.getPort();
   } catch (MalformedURLException mue) {
     return -1;
   }
 }
Example #3
0
  void showContent() {
    URL address = null;

    try {
      address = new URL(addressTextField.getText());
    } catch (MalformedURLException mue) {
      showWarning(mainFrame, "地址输入错误");
    }

    System.out.println("getProtocol() " + address.getProtocol());
    System.out.println("getHost() " + address.getHost());
    System.out.println("getPort() " + address.getPort());
    System.out.println("getPath() " + address.getPath());
    System.out.println("getFile() " + address.getFile());
    System.out.println("getQuery() " + address.getQuery());
  }
Example #4
0
 /** ** Sets the 'host' */
 public boolean setHost(String _host) {
   String uri = this.getURI();
   if (!StringTools.isBlank(_host) && URIArg.isAbsoluteURL(uri)) {
     try {
       URL oldURI = new URL(uri);
       String proto = oldURI.getProtocol();
       String host = _host;
       int port = oldURI.getPort();
       String file = oldURI.getFile();
       URL newURI = new URL(proto, host, port, file);
       this._setURI(newURI.toString());
       return true;
     } catch (MalformedURLException mue) {
       // error
     }
   }
   return false;
 }