WriteStream ws = null;
try {
Path path = getPath(request);
QuercusPage page;
try {
page = getQuercus().parse(path);
}
catch (FileNotFoundException ex) {
// php/2001
log.log(Level.FINER, ex.toString(), ex);
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
StreamImpl out;
try {
out = new VfsStream(null, response.getOutputStream());
}
catch (IllegalStateException e) {
WriterStreamImpl writer = new WriterStreamImpl();
writer.setWriter(response.getWriter());
out = writer;
}
ws = new WriteStream(out);
ws.setNewlineString("\n");
Quercus quercus = getQuercus();
quercus.setServletContext(_servletContext);
env = quercus.createEnv(page, ws, request, response);
try {
env.start();
env.setScriptGlobal("request", request);
env.setScriptGlobal("response", response);
env.setScriptGlobal("servletContext", _servletContext);
StringValue prepend
= quercus.getIniValue("auto_prepend_file").toStringValue(env);
if (prepend.length() > 0) {
Path prependPath = env.lookup(prepend);
if (prependPath == null)
env.error(L.l("auto_prepend_file '{0}' not found.", prepend));
else {
QuercusPage prependPage = getQuercus().parse(prependPath);
prependPage.executeTop(env);
}
}
env.executeTop();
StringValue append
= quercus.getIniValue("auto_append_file").toStringValue(env);
if (append.length() > 0) {
Path appendPath = env.lookup(append);
if (appendPath == null)
env.error(L.l("auto_append_file '{0}' not found.", append));
else {
QuercusPage appendPage = getQuercus().parse(appendPath);
appendPage.executeTop(env);
}
}
// return;
}
catch (QuercusExitException e) {