1

I have this code in my jsp

    <script  type="text/javascript">

    function myJsFunction() {
       var queryString = new QueryString();
        queryString.add('initDate', document.getElementById('${id}').value);
    }

And it is working. I want document.getElementById('${id}').value to pass throught my tag lib and I add

 <%@ taglib prefix="my" uri="http://tags/my"%>


    <script  type="text/javascript">

    function myJsFunction() {
       var queryString = new QueryString();
        queryString.add('initDate', ${my:myTagFunc(document.getElementById('${id}').value)});
    }

But is slowing empty despite that document.getElementById('${id}').value returns a String. I can not understand why?

Xelian
  • 16,680
  • 25
  • 99
  • 152
  • I don't get what you want to do, do you have a method named `function` in a custom tag library named `my`? – Pablo Lozano Feb 03 '17 at 11:53
  • @Pablo sorry in my tab library there is function called my:myTagFunc – Xelian Feb 03 '17 at 12:05
  • 1
    You cannot do that. as `${my:myTagFunc()}` will execute on server side and its parameter is supplied by `document.getElementById`, You should create a API and use `AJAX` call to get data – Satpal Feb 03 '17 at 12:07

1 Answers1

2

You are mixing two different codes. The key is to realize, where and when each code is executed - JSP on the server when the page is requested and rendered (i.e. before the response is sent to the browser) and Javascript in the browser, after the browser receives the already generated response.

As commented by Satpal, you need AJAX.

Community
  • 1
  • 1
Jozef Chocholacek
  • 2,874
  • 2
  • 20
  • 25