Pass Javascript Value to Java in JSP

前端 未结 2 556
渐次进展
渐次进展 2020-12-11 23:45

I would like to pass a Javascript value to a Java function in JSP. How can I do that? The id comes from a combobox in JSP via Javascript. I will get the ID from ComboBox and

2条回答
  •  天涯浪人
    2020-12-12 00:07

    You cannot make a server call directly. You need to make a server request.

    javascript plays on client side and JSP plays on server side.

    What you need is you have to make a server request. And send that string as a query parameter.

    Two options to achieve this.

    • HTML forms
    • Ajax.

    Do not confuse that JSP and java script existed on same document(or file). Yes but JSP part compiles on server side and JavaScript executes by browser.

提交回复
热议问题