System.out.println("name before = " + name); System.out.println("name after = " + name);
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)        throws IOException, ServletException {        try {            if (servletRequest instanceof HttpServletRequest) {                HttpServletRequest httpServletRequest = (HttpServletRequest)servletRequest;                Map map = servletRequest.getParameterMap();                if (map.containsKey(RECORDER_SCRIPT)) {                    logger.info("recorder_script " + map.get(RECORDER_SCRIPT));                    String[] values = (String[])map.get(RECORDER_SCRIPT);                    scriptName = values[0];                }                if (map.containsKey(RECORDER_START)) {                    if (list != null)                        return;                    logger.info(RECORDER_START);                    list = new LinkedList();                }                else if (map.containsKey(RECORDER_STOP)) {                    if (list == null)                        return;                    logger.info(RECORDER_STOP);                    writeCode();                    list = null;                }                else if (list != null) {                    String resource = httpServletRequest.getPathInfo();                    System.out.println("PATH_INFO: " + resource);                    Request record;                    if ("GET".equalsIgnoreCase(httpServletRequest.getMethod()))                        record = new GET(resource);                    else                        record = new POST(resource);                    Enumeration parameterNames = httpServletRequest.getParameterNames();                    while (parameterNames.hasMoreElements()) {                        String name = (String)parameterNames.nextElement();                        String[] values = httpServletRequest.getParameterValues(name);                        System.out.println("name before = " + name);                        System.out.println("name after = " + name);                        addEvent(record, name, values);                    }                    Enumeration headerNames = httpServletRequest.getHeaderNames();                    while (headerNames.hasMoreElements()) {                        String name = (String)headerNames.nextElement();                        if (name.equalsIgnoreCase("cookie") ||                            name.equalsIgnoreCase("referer"))                            continue;                        addHeader(record, name, httpServletRequest.getHeader(name));                    }                    list.add(record);                }            }        }        finally {            if (servletResponse instanceof HttpServletResponse) {                filterChain.doFilter(servletRequest, new HttpServletResponseWrapper((HttpServletResponse)servletResponse) {                    public ServletOutputStream getOutputStream() throws IOException {                        final ServletOutputStream out = super.getOutputStream();                        return new ServletOutputStream() {                            public void write(int b) throws IOException {                                out.write(b);                            }                            public void close() throws IOException {                                super.println("<hr/><div align=\"center\">");                                super.println("<form method=\"get\" action=\"\">");                                super.println("<input type=\"text\" name=\"recorder_script\" value=\"" + scriptName + "\">");                                super.println("<input type=\"submit\" name=\"recorder_start\" value=\"start\">");                                super.println("<input type=\"submit\" name=\"recorder_stop\" value=\"stop\">");                                super.println("</div></form>");                                super.close();                            }                        };                    }                });            }            else                filterChain.doFilter(servletRequest, servletResponse);        }    }