With JSR-223 you can use the embedded JavaScript engine of Java 6 (beware, this will not work on clients running on Java 5).
Just start your script code with #!javascript in the first line.
Btw. the line "#!beanshell" could be omitted - BeanShell is (for historical reasons) the default script engine.