Calling the Java function from within a scriptlet which you can place inside a Javascript function which is invoked on the onClick event.
The net result is the same as invoking a Java function from an onClick event.
Not so!
The JSP is executed on the server long long before the resulting response is sent back to the client. The embedded Java call is executed
as the page is being constructed and in no way can be invoked as a part of the onclick handler.
"Embedding" a Java function in a JS function only serves to "write" the results of the Java function to the body of the JS function. Which is not even remotely the same thing as "calling" the Java function as part of the JS function.