-1

I want to use javascript value in jstl function on jsp page which call function in managedbean. anyone help.

Javascript code:

alert(document.getElementById('data').value);
                    '${mapBean.testfunc(document.getElementById('data').value)}';

managedbean:

 public void testfunc(String a) {
        System.out.println("my function test is printed"+a);
    }
sam mari
  • 145
  • 1
  • 2
  • 9

1 Answers1

0

I don't work with JSP, but I don't think this is possible. Websites use a Client-Server-Model. The Java-Code (Beans) are executed on the server, the Javascript-Code is executed in the browser on the client (AFTER the website already left the server).

To communicate back from javascript-code on a webpage to the server, you have to use AJAX-Calls. This is a new HTTP-Request which doesn't reload the page but gets processed by your own javascript-code.

Maybe this tutorial can help you: http://howtodoinjava.com/2013/06/21/complete-ajax-tutorial/

Johannes Reuter
  • 3,501
  • 19
  • 20