0

Hello I have just finished my very first applet in Java : http://st.fri.uniza.sk/~mudrak3/index2

What it does is basicaly it goes through websites source code and finds any links and appends them into textArea.

If I put that website link into textField (http://st.fri.uniza.sk/~mudrak3/index2) and hit button it all works. Button event :

private void button1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
    textArea1.setText("\f");
    try {
        ArrayList<String> array = new ArrayList<String>();
        ArrayList<String> vystup = new ArrayList<String>();
        URL adresa;
        adresa = new URL(textField1.getText());
        BufferedReader kod = new BufferedReader(new InputStreamReader(adresa.openStream()));
        String riadok;
        while ((riadok = kod.readLine()) != null) {
            array.add(riadok);
            String[] pom = riadok.split(" ");
            String xxx;
            Pattern pattern = Pattern.compile("http://[^ \"]+");
            for (int i = 0; i < pom.length; i++) {
                xxx = pom[i];
                Matcher matcher = pattern.matcher(xxx);
                if (matcher.find()) {
                    textArea1.append(matcher.group(0) + "\n");
                }
            }
        }
        textArea1.append("---------Koniec---------");
    } catch (MalformedURLException ex) {
        JOptionPane.showMessageDialog(null, "Zle zadana URL !");
    } catch (IOException ex) {
        JOptionPane.showMessageDialog(null, "IOException !");
    }

}

Any other website doesn't work. This app works in NetBeans as I run the applet, but not on the website. Any help ?

Jørgen R
  • 10,568
  • 7
  • 42
  • 59
Lubos Mudrak
  • 651
  • 1
  • 8
  • 26

1 Answers1

1

In order to reach across domains, an applet needs to be:

  1. Digitally signed by you.
  2. Accepted by the user when prompted.
Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433