@SuppressWarnings("unchecked")
    public Object invoke(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        if (type == Type.FORWARD) {
            request.getRequestDispatcher(target).forward(request, response);
        } else if (type == Type.REDIRECT || type == Type.RELOCATE) {
            StringBuilder out = new StringBuilder(target);
            boolean first = target.indexOf('?') == -1;
            
            Map<String, String[]> map = (Map<String, String[]>)request.getParameterMap();
            for (String key : map.keySet()) {
                String[] values = map.get(key);
                for (String value : values) {
                    if (first) {
                        first = false;
                        out.append("?");
                    } else {
                        out.append("&");
                    }
                    
                    out.append(URLEncoder.encode(key, "utf-8"));
                    out.append("=");
                    out.append(URLEncoder.encode(value, "utf-8"));
                }
            }
            
            if (type == Type.REDIRECT) {
                response.sendRedirect(out.toString());
            } else {
                response.setHeader("Location", out.toString());
                response.setHeader("Connection", "close");
                response.setStatus(301);
            }
        } else if (type == Type.DEPLOY) {
            try {
                Page handler = pageClass.newInstance();
                request.setAttribute(AttributeNames.PAGE, handler);              
                request.getRequestDispatcher(target).forward(request, response);
            } catch (Exception ex) {
                throw new ServletException(ex);
            }
        }
        
        return null;
    }