in src/java/org/apache/turbine/services/jsp/TurbineJspService.java [138:194]
public void handleRequest(PipelineData pipelineData, String templateName, boolean isForward)
throws TurbineException
{
if(!(pipelineData instanceof RunData))
{
throw new RuntimeException("Can't cast to rundata from pipeline data.");
}
RunData data = (RunData)pipelineData;
/** template name with relative path */
String relativeTemplateName = getRelativeTemplateName(templateName);
if (StringUtils.isEmpty(relativeTemplateName))
{
throw new TurbineException(
"Template " + templateName + " not found in template paths");
}
// get the RequestDispatcher for the JSP
RequestDispatcher dispatcher = data.getServletContext()
.getRequestDispatcher(relativeTemplateName);
try
{
if (isForward)
{
// forward the request to the JSP
dispatcher.forward(data.getRequest(), data.getResponse());
}
else
{
data.getResponse().getWriter().flush();
// include the JSP
dispatcher.include(data.getRequest(), data.getResponse());
}
}
catch (Exception e)
{
// Let's try hard to send the error message to the browser, to speed up debugging
try
{
data.getResponse().getWriter().print("Error encountered processing a template: "
+ templateName);
e.printStackTrace(data.getResponse().getWriter());
}
catch (IOException ignored)
{
// ignore
}
// pass the exception to the caller according to the general
// contract for templating services in Turbine
throw new TurbineException(
"Error encountered processing a template: " + templateName, e);
}
}