passing java script value to java method in JSP

553 views Asked by At

I am trying to pass java script value to java method in JSP.

But it is NOT working. Can anybody please tell how I can achieve this or is there any alternative solution for this ?

<script type="text/javascript">
   function myjsfunc(){
       var myef = $(this).data('myrefval');
       var myurl ="http://example.com/mycontext?param="+myef;
       var myurlData = '<%=callJavaMethod(myurl)%>'; // this is NOT working.It is Not understanding myurl variable
       processData(myurlData);
    }
    function processData(finaldata){
    }
<script>

<%!
public String callJavaMethod(String param){
  System.out.println(param); // process here param and return string data
}
%>
0

There are 0 answers