Yup, you are barking up a very wrong tree. Forget all about all of that ScriptEngine stuff -- that's not what you are after.
In fact, forget about JSP and
Java for the moment too.
What you need to do is to learn how to use JavaScript in
HTML pages -- because all JSP does is to specify a template for HTML pages. Your Java code won't know anything about the JavaScript executing on the browser.
The good news is that it's a lot easier to get JavaScript running on an HTML page than all that wrong direction you were headed in. All you need is <script> tags in the JSP (and, of course, to learn JavaScript).