I think you can pass the JSP variable as an argument to the javascript function. But I dont have any idea to do the reverse. But I wonder why you need to use the javascript variable in the JSP function.
JSP and Javascript cannot interoperate. JSP is executed on the server to format and send the HTML page to the browser. Your JSP can dynamically create the Javascript that will be executed when it gets there, but that's the extent to which they intersect.