Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8604767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:39:27+00:00 2026-06-12T02:39:27+00:00

In my Django web page I need Javascript to call a public method of

  • 0

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.

Here is the code.

HTML:

<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.1.min.js"></script>

<applet name="mapGenerator"
    code="MapGenerator.class"
    archive="{{STATIC_URL}}java/MapGenerator.jar"
    width= 500 height = 300>

        <param name=numero_immagini value="{{floor.count}}">
        <param name=id value="{{building.id}}">
        {% for f in floor %}
            <param name=immagine{{forloop.counter0}} value="{{MEDIA_URL}}{{f.link.name}}">
            <param name=numero_piano{{forloop.counter0}} value="{{f.numero_di_piano}}">
        {%endfor%}
</applet>

<script type="text/javascript">
    function initialize() {
        document.mapGenerator.setCookie(document.cookie);
    }
</script>

<body onload="initialize()">

Class MapGenerator:

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< 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();
    }
}

When I open this web page, this is the error in JS console:

Uncaught TypeError: Object #<HTMLAppletElement> has no method 'setCookie'

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:39:29+00:00Added an answer on June 12, 2026 at 2:39 am

    I cannot believe that was such a stupid thing…

    I only have to put the script

    <script type="text/javascript">
        function initialize() {
            document.mapGenerator.setCookie(document.cookie);
        }
    </script>
    

    BEFORE the applet… I’m going to cry…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a web page using django and I want to add some javascript
I need to code some complicated web page with new html5 features, using javascript
I have a page web method, and I need to get access to the
I have recently started experimenting with Django for some web applications in my spare
I have java sdk 1.7. I've always used django/python for web development, this will
I used lxml to parse some web page as below: >>> doc = lxml.html.fromstring(htmldata)
I can make the same in Django using render_to(...) but ASP.NET. I need to
I am working on a Django web based project in which i need to
I am attempting to build a django based web page (I know python and
I have a web application written in Django that has one specific page I'd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.