throw new ProcessingException("HttpServletRequest or HttpServletResponse or ServletContext object not available");
}
JSPEngine engine = null;
Parser parser = null;
Source src = null;
try {
src = this.resolver.resolve(this.source);
String url = src.getSystemId();
// Guarantee src parameter is a file
if (!url.startsWith("file:/"))
throw new IOException("Protocol not supported: " + url);
url = url.substring(5);
getLogger().debug("JspGenerator executing JSP:" + url);
engine = (JSPEngine)this.manager.lookup(JSPEngine.ROLE);
byte[] bytes = engine.executeJSP(url, httpRequest, httpResponse, httpContext);
// explicitly specify bytestream encoding
InputSource input = new InputSource(new ByteArrayInputStream(bytes));
input.setEncoding("utf-8");
// pipe the results into the parser
parser = (Parser)this.manager.lookup(Parser.ROLE);
parser.setConsumer(this.xmlConsumer);
parser.parse(input);
} catch (ServletException e) {
getLogger().debug("ServletException in JspGenerator.generate()", e);
getLogger().debug("Embedded ServletException JspGenerator.generate()", e.getRootCause());
throw new ProcessingException("ServletException in JspGenerator.generate()",e.getRootCause());
} catch (SAXException e) {
getLogger().debug("SAXException JspGenerator.generate()", e);
getLogger().debug("Embedded SAXException JspGenerator.generate()", e.getException());
throw new ProcessingException("SAXException JspGenerator.generate()",e.getException());
} catch (IOException e) {
getLogger().debug("IOException in JspGenerator.generate()", e);
throw new ProcessingException("IOException JspGenerator.generate()",e);
} catch (ProcessingException e) {
throw e;
} catch (Exception e) {
getLogger().debug("Exception in JspGenerator.generate()", e);
throw new ProcessingException("Exception JspGenerator.generate()",e);
} finally {
if (src != null) src.recycle();
if (parser != null) this.manager.release(parser);
if (engine != null) this.manager.release(engine);
}
}