how to return value from groovy to java
- by Sid
Hi
I am very new to groovy and having trouble with some parts.
I have a jsp page tied to a servlet that runs groovy scripts. I am able to get to the groovy script from the servlet. But after the script runs how do I return the response from the groovy script back to the servlet to be displayed in the jsp page?
My java servlet code is as follows:
File file = new File("TestScript.groovy");
ClassLoader parent = getClass().getClassLoader();
GroovyClassLoader loader = new GroovyClassLoader(parent);
Class groovyClass = loader.parseClass(file);
Object[] args = {};
GroovyObject groovyObject = (GroovyObject) groovyClass.newInstance();
groovyObject.invokeMethod("runTest", args);