// ensure that we are running in a servlet environment
if (servletResponse == null || servletRequest == null || servletContext == null) {
throw new ProcessingException("JSPReader can only be used from within a Servlet environment.");
}
JSPEngine engine = null;
Source inputSource = null;
Source contextSource = null;
try {
inputSource = this.resolver.resolveURI(this.source);
contextSource = this.resolver.resolveURI("context:/");
String inputSourceURI = inputSource.getURI();
String contextSourceURI = contextSource.getURI();
if (!inputSourceURI.startsWith(contextSourceURI)) {
throw new ProcessingException("You must not reference a file "
+ "outside of the servlet context at " + contextSourceURI + ".");
}
String url = inputSourceURI.substring(contextSourceURI.length());
if (url.charAt(0) != '/') {
url = "/" + url;
}
if (getLogger().isDebugEnabled()) {
getLogger().debug("JSPReader executing:" + url);
}
engine = (JSPEngine) super.manager.lookup(JSPEngine.ROLE);
byte[] bytes = engine.executeJSP(url, servletRequest, servletResponse, servletContext);
if (this.outputEncoding != null) {
recodeResult (bytes, this.outputEncoding);
} else {
out.write(bytes);