简体   繁体   中英

How to insert javascript inside a java scriplet in JSP?

Here is my function:

var boxName = document.getElementById('searchBox').value;

How can I put the value of boxName inside the scriplet like this?

<%BoxList.getInstance().getBoxListNames().contains(boxName);%>

--Not Possible

You might misunderstand that jsp and javascript existed on same document.Yes but JSP part compiles on server side itself comes to client.

Java script 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 a query parameter.

And please prefer to read How to avoid Java code in JSP files?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM