As already pointed out, you cannot call a Java method from JavaScript, even in a JSP. Please read
this article to understand how JSP operates and why Java is not available in the JavaScript on a JSP page.
In order to have JavaScript obtain values from the server, you must use Ajax to create a request to the server that can invoke a
servlet that will return the desired values as the response.
If you are working with web applications, you must learn Ajax. It's a required part of the technology set required to write modern web apps.
P.S. Using jQuery makes using Ajax much simpler.