Rikkin
Rikkin

Reputation: 509

Pass variables from java to javascript

I'm new to JavaScript programming, and I have a question that I could not find an answer to anywhere.

I have some code in Java that does some stuff with two double arrays

double[] arrX = new double[sizeA];
double[] arrY = new double[sizeB];

Then, I need to pass these two variables to a html/JavaScript code that need to use them.

Is that possible?

Upvotes: 2

Views: 6158

Answers (1)

Sachin Thapa
Sachin Thapa

Reputation: 3709

Would recommend following:

  1. Install apached tomcat http://tomcat.apache.org/tomcat-6.0-doc/appdev/

  2. Try Hello World example included in Apached Tomcat http://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/

You would find values in variables shown in GUI.

Next Step assigning java variables to javascript variables, use following syntax

<script type="text/javascript">
var jsVariable =<%javaVariable%>;
</script>

Hoping this helps.

Cheers !!

Upvotes: 1

Related Questions