JavaScript to interact with Java

2

You can get a javascript value and put it inside a variable in java .

EX:

var len = $(" #relacaoPax select[name=tipo] ").length;
        console.log( "len = " + len );
    });
<% int l = len;
   System.out.println( "//L = " + l );
%>
    
asked by anonymous 22.07.2014 / 19:04

2 answers

1

You can not do what you want because all the JAVA code on your page is processed on the server, and when you get to the browser there will only be HTML and JAVASCRIPT code to be interpreted.

    
23.07.2014 / 21:31
1

You would need to use AJAX on your page.

If you are using JSF, take a look at the f:ajax tag. ( link )

JSP + Servlet: link

    
24.07.2014 / 18:19