Connect java and javascript [closed]

-1

You can inform me about how to pass variable values between java and javaScript, as well as how I can call java methods from javascript Thank you very much for your help.

    
asked by Javier Reyero Huerga 31.05.2017 в 14:56
source

1 answer

0

As you are beginning, perhaps the simplest and most primitive way is through JSP (java server page). Allows you to directly send data from java to javaScript. The jsp pages are compiled into an html that is sent to the client.

Here is a simple example:

<%
  String str="Hello world";
%>
<script>
    var jsvar = <%=str%>;
</script>

Once you know the JSPs, you could use libraries above JSP as JSTL: link

Of course, you should not stop looking at Servlets and ajax calls either. Here you have information about a simple implementation of stackOverflow with different javaScript libraries against Java Serlvets: link

    
answered by 31.05.2017 / 15:14
source