title: Call public Java method from javascript error
body: <p>In my Django web page I need Javascript to call a public method of a java applet.
  I want to make the java applet POST some data to the DJango webserver, but to do this I need the cookie to authenticate session.
  With this in mind I found out that I can call public methods of my applet from JS, so I tried it, and it failed.
  I don't know which is the problem, or if I'm missing something.</p>
  
  <p>Here is the code.</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.1.min.js"&gt;&lt;/script&gt;
  
  &lt;applet name="mapGenerator"
      code="MapGenerator.class"
      archive="{{STATIC_URL}}java/MapGenerator.jar"
      width= 500 height = 300&gt;
  
          &lt;param name=numero_immagini value="{{floor.count}}"&gt;
          &lt;param name=id value="{{building.id}}"&gt;
          {% for f in floor %}
              &lt;param name=immagine{{forloop.counter0}} value="{{MEDIA_URL}}{{f.link.name}}"&gt;
              &lt;param name=numero_piano{{forloop.counter0}} value="{{f.numero_di_piano}}"&gt;
          {%endfor%}
  &lt;/applet&gt;
  
  &lt;script type="text/javascript"&gt;
      function initialize() {
          document.mapGenerator.setCookie(document.cookie);
      }
  &lt;/script&gt;
  
  &lt;body onload="initialize()"&gt;
  </code></pre>
  
  <p>Class MapGenerator:</p>
  
  <pre><code>public class MapGenerator extends JApplet {
  
      //... variables
  
      public void init() {
          numero_immagini = Integer.parseInt(this.getParameter(N_IMMAGINI));
          id_building = Integer.parseInt(this.getParameter(ID_BUILDING));
          images = new BufferedImage[numero_immagini];
          floors = new int[numero_immagini];
  
          for(int i=0; i&lt; numero_immagini; i++) {
              try {
                  URL url = new URL(getCodeBase(), this.getParameter(IMMAGINE+i));
                      images[i] = ImageIO.read(url);
                      floors[i] = Integer.parseInt(this.getParameter(PIANO_IMMAGINE+i));
              } catch (IOException ioe) {ioe.printStackTrace();}
          }
      }
  
      public void setCookie(String cookie) {
          this.cookie = cookie;
          ed.cookie = cookie;
          System.err.println(cookie);
      }
  
      public void start() {
  
          ed = new Editor(this.getContentPane(), images, floors, id_building);                     
          this.add(ed.getPanel());
          Toolkit kit = this.getToolkit();
          Dimension dim = kit.getScreenSize();
          this.setBounds(dim.width/4, dim.height/4, dim.width/4, dim.height/4);
          this.setVisible(true);
          this.repaint();
      }
  }
  </code></pre>
  
  <p>When I open this web page, this is the error in JS console:</p>
  
  <pre><code>Uncaught TypeError: Object #&lt;HTMLAppletElement&gt; has no method 'setCookie'
  </code></pre>
  
  <p>Thank you</p>