2

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?

5
  • 8
    You need to learn AJAX. Commented Jul 17, 2013 at 14:28
  • The above comment answered your question. Commented Jul 17, 2013 at 14:29
  • 2
    Not necessarily AJAX. They could be set as request attributes to be picked up in a JSP. But we don't know nearly enough about the OPs application to offer much help. Commented Jul 17, 2013 at 14:36
  • 1
    False. Its also possibly done as a Java Server Page (JSP) Edit: GriffeyDog was faster :) Commented Jul 17, 2013 at 14:37
  • Yes, it's possible. It can be done in multiple ways and it depends on the architecture of your app and the frameworks that you are using. Commented Jul 17, 2013 at 14:39

1 Answer 1

1

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 !!

Sign up to request clarification or add additional context in comments.

2 Comments

You better not give an example of scriplets to a newcomer.. :) Just give a hand in researching of Servlet API and JSP would be good.
@ConstantineNovykov - You are right, just though to tell hiim its possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.