Just to be clear: JSP is a server-side technology, while JavaScript is a client-side technology. JSP can't access JS, and vice-versa. What JSP can do is generate JS code in the web page it generates, and that JS code can call other JS code that gets included in the web page from an external JS file. If this doesn't address your problem, describe in more detail what you're stuck with.
If it does not work when you move it from inline to the js file it usually means three things. Not linking the external file correctly, you put script tags inside of the external js file, or you did a bad copy and paste job and cut off some brackets or letters.