Can't be done. That's not the way things work.
All of the code in your
JSP executes on the server in order to compose a plain-old vanilla HTML/Javascript page to send to the browser. Once it gets there, your JSP is long gone and reclaimed (a simplificiation, but close enough for now).
So by the time your Javascript function finally gets around to executing, the Java is not there -- it executed long ago in order to render the page. Take a look at the results of a View Source to see what's being sent to the browser.
The only interaction possible between the client (your Javascript) and the server (your Java) is through the normal request/response HTTP cycle.