All pastes #621886 Raw Edit

Meins

public java v1 · immutable
·published 2007-07-16 14:10 UTC
rendered paste body
// 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("<script type=\"text/javascript\">console.error('" + e.getMessage() + "');</script>");			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());		}	}