Example usage for org.apache.commons.httpclient.contrib.proxy ProxyDetectionException printStackTrace

List of usage examples for org.apache.commons.httpclient.contrib.proxy ProxyDetectionException printStackTrace

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.contrib.proxy ProxyDetectionException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.apache.commons.httpclient.contrib.proxy.PluginProxyTestApplet.java

private void detectProxy() {
    String urlString = urlTextField.getText();
    if (urlString == null || "".equals(urlString)) {
        JOptionPane.showMessageDialog(super.getRootPane(), "URL can't be empty", "Missing URL",
                JOptionPane.ERROR_MESSAGE);
        return;// w  ww .j  a  va 2 s . c om
    }
    if (!urlString.startsWith("http://")) {
        urlString = "http://" + urlString;
    }
    try {
        URL url = new URL(urlString);
        HttpHost hostInfo = PluginProxyUtil.detectProxy(url);
        if (hostInfo != null) {
            hostLabel.setText(hostInfo.getHostName());
            portLabel.setText("" + hostInfo.getPort());
        } else {
            hostLabel.setText("none");
            portLabel.setText("none");
        }
        grid.validate();
    } catch (ProxyDetectionException e) {
        JOptionPane.showMessageDialog(getRootPane(), e.getMessage(), "Proxy Detection Failed",
                JOptionPane.ERROR_MESSAGE);
        e.printStackTrace();
    } catch (Exception e) {
        JOptionPane.showMessageDialog(getRootPane(), e.getMessage(), "Unexpected Exception",
                JOptionPane.ERROR_MESSAGE);
        e.printStackTrace();
    }
}