// Invoke the JSP to render, replace with the actual jsp name try { Context context = Context.enter(); Scriptable scope = context.initStandardObjects(); eval(context, scope, "env"); Object result = eval(context, scope, "marketadmin"); System.out.println(result); response.getWriter().write(result.toString()); Context.exit(); } catch (RhinoException e) { response.getWriter().write(""); e.printStackTrace(); } catch (Throwable e) { e.printStackTrace(); } } private Object eval(Context context, Scriptable scope, String name) { try { return context.evaluateReader(scope, findFile(name), name + ".js", 1, null); } catch (IOException e) { throw new RuntimeException(e); } } private Reader findFile(String filename) { try { return new FileReader(getPortletConfig().getPortletContext().getRealPath("/jquery-mvc/" + filename + ".js")); } catch (FileNotFoundException e) { throw new IllegalArgumentException(e.getMessage()); } }