StringWriter writer = new StringWriter(new CharBuffer(1024));
writer.openWrite();
ByteArrayInputStream bais = new ByteArrayInputStream(templateAsString.getBytes());
VfsStream stream = new VfsStream(bais, null);
QuercusPage page = quercus.parse(new ReadStream(stream));
WriteStream ws = new WriteStream(writer);
Env env = quercus.createEnv(page, ws, deliveryContext.getHttpServletRequest(), deliveryContext.getHttpServletResponse());
env.start();
Value value = page.executeTop(env);
ws.flush();
String output = ((StringWriter)ws.getSource()).getString();
Object returnObject = value.toJavaObject();
//logger.info("output:" + output);
pw.println(output);
}
catch (Throwable e)
{
e.printStackTrace();
}
}
else if(scriptController != null)
{
scriptController.getRequest().setAttribute("org.infoglue.cms.deliver.scriptLogic", scriptController);
scriptController.getRequest().setAttribute("org.infoglue.cms.deliver.portalLogic", portletController);
scriptController.getRequest().setAttribute("model", model);
try
{
QuercusContext quercus = new QuercusContext();
quercus.setServletContext(scriptController.getRequest().getSession().getServletContext());
Path pwd = new FilePath(CmsPropertyHandler.getContextRootPath());
quercus.setPwd(pwd);
if (! Alarm.isTest() && ! quercus.isResin()) {
Vfs.setPwd(pwd);
WorkDir.setLocalWorkDir(pwd.lookup("WEB-INF/work"));
}
quercus.init();
quercus.start();
StringWriter writer = new StringWriter(new CharBuffer(1024));
writer.openWrite();
ByteArrayInputStream bais = new ByteArrayInputStream(templateAsString.getBytes());
VfsStream stream = new VfsStream(bais, null);
QuercusPage page = quercus.parse(new ReadStream(stream));
WriteStream ws = new WriteStream(writer);
Env env = quercus.createEnv(page, ws, scriptController.getRequest(), scriptController.getResponse());
env.start();
Value value = page.executeTop(env);
ws.flush();
String output = ((StringWriter)ws.getSource()).getString();
Object returnObject = value.toJavaObject();