public void handle(String path,
                       Request baseRequest,
                       HttpServletRequest request,
                       HttpServletResponse response)
            throws IOException, ServletException {
        response.setStatus(HttpServletResponse.SC_OK);

        final int length = path.length();
        if (length != 1 && path.charAt(length - 1) == '/') {
            path = path.substring(0, length - 1);
        }

        TargetHandler handler = m_handlers.get(path);
        if (handler != null) {
            baseRequest.setHandled(true);
            handler.setHandlerParam(request, response);
            response.getWriter().write(handler.handle(new Path(path, path)));
        } else {
            for (final String target : m_targets) {
                if (Path.isAppropriate(target, path)) {
                    baseRequest.setHandled(true);
                    handler = m_handlers.get(target);
                    handler.setHandlerParam(request, response);
                    response.getWriter().write(handler.handle(new Path(path, target)));
                    break;
                }
            }
        }
    }