Getting value from a scriptlet into javascript is pretty simple. However the otherway round which means getting a value from a scriptlets into javascript may not be too simple.
You could probably have a hidden parameter, have its
value = <%=request.getParameter(“value”) %>
and how this request parameter is going to get populated is, when you have the jsp submit the request to itself, i.e., have the action = to the same jsp page. For submitting the page to another action, you will have to write a submitForm() method and have it populated with this.form.action=youraction and then submit it.
Now on to the main topic, to get a value from scriptlet into javascript you could :
String a = “abc”;
Then make a hidden element in our good old HTML
<input type=”hidden” name=”testa” id=”testa” value=<%= a%> >
In the javascript where you want to fetch the value, you can do a
document.getElementById(“testa”).value;
thats all.