tracingLogger.log(MvcJspEvent.JSP_FORWARD, templateReference, resolvedViewable.getModel());
}
final RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(templateReference);
if (dispatcher == null) {
throw new ContainerException(LocalizationMessages.NO_REQUEST_DISPATCHER_FOR_RESOLVED_PATH(templateReference));
}
final RequestDispatcher wrapper = new RequestDispatcherWrapper(dispatcher, getBasePath(), resolvedViewable);
// OutputStream and Writer for HttpServletResponseWrapper.
final ServletOutputStream responseStream = new ServletOutputStream() {
@Override
public void write(final int b) throws IOException {
out.write(b);
}
};
final PrintWriter responseWriter = new PrintWriter(new OutputStreamWriter(responseStream, getEncoding()));
try {
wrapper.forward(requestProviderRef.get().get(), new HttpServletResponseWrapper(responseProviderRef.get().get()) {
@Override
public ServletOutputStream getOutputStream() throws IOException {
return responseStream;
}
@Override
public PrintWriter getWriter() throws IOException {
return responseWriter;
}
});
} catch (final Exception e) {
throw new ContainerException(e);
} finally {
responseWriter.flush();
}
}