public void doFilter(final ServletRequest req, final ServletResponse resp, final FilterChain chain)
throws IOException, ServletException
{
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = new PrettyFacesWrappedResponse(request.getContextPath(), request,
(HttpServletResponse) resp, getConfig());
req.setAttribute(PrettyContext.CONFIG_KEY, getConfig());
PrettyContext context = PrettyContext.newDetachedInstance(request);
rewrite(request, response);
if (resp.isCommitted())
{
log.trace("Rewrite occurred, reponse is committed - ending request.");
}
else
{
URL url = context.getRequestURL();
if (getConfig().isURLMapped(url))
{
PrettyContext.setCurrentContext(request, context); // set
String viewId = context.getCurrentViewId();
if (!response.isCommitted())
{
if (context.shouldProcessDynaview())
{
log.trace("Forwarding mapped request [" + url.toURL() + "] to dynaviewId [" + viewId + "]");
req.getRequestDispatcher(context.getDynaViewId()).forward(req, response);