javajavascriptappletliveconnect

Size of the parameter in applet call is too big


I have problem in passing some data from JavaScript to an applet. I think size of data is too big (18M characters in string) to pass it through LiveConnect.

I put code samples below:

JavaScript:

var bigData = generateSomeBigData(18000000); // string contaning 18 000 000 characters
applet.Execute(bigData); // no error

Applet:

public void Execute(String data) {
    this.doSomethingWithData(data);  // data is null
}

I didn't get any error or exceptions in java console or in javascript code. I've tried running applet with bigger heap, but it didn't help.

... <param name="java_arguments" value="-Xmx128m" /> ...

The only problem is I get null instead of string contaning data, it doesn't depend on browser (FF, Chrome).


Solution

  • I solved this problem. I moved data generation to server site and I'm passing data to applet using one time self destructing link. Applet can download information, which is no more available, and return result.

    Here you have an example:

    Server:

    String bigData = this.generateBigData(18000000);
    String linkToData = this.getOneTimeLink(bigData);
    

    JavaScript:

    applet.Execute(linkToBigData);
    

    Applet:

    public void Execute(String link) {
        String data = this.downloadData(link);
        this.doSomethingWithData(data);  // data is not null ;)
    }
    

    EDIT 11 May 2015:

    Maybe you need a small explanation to one time destructing link. I used it because it was another requirement to my project but it is not necessary to achieve solution.