How do I pass Javascript variable to and JSTL?
<script>
var name = "john";
<jsp:setProperty name="emp" property="firstName" value=" "/> // How do I set javascript variable(name) value here ?
<c:set var="firstName" value=""/> // How do I set javascript variable (name) value here ?
</script>
You need to send it as a request parameter. One of the ways is populating a hidden input field.
This way you can get it in the server side as request parameter when the form is been submitted.
An alternative way is using Ajax, but that’s a completely new story/answer at its own.
See also:
If you can’t seem to find your previously asked questions back, head to your user profile!