1 package org.jbpm.webapp.filter; 2 3 import java.io.IOException ; 4 import java.util.Enumeration ; 5 6 import javax.servlet.Filter ; 7 import javax.servlet.FilterChain ; 8 import javax.servlet.FilterConfig ; 9 import javax.servlet.ServletException ; 10 import javax.servlet.ServletRequest ; 11 import javax.servlet.ServletResponse ; 12 import javax.servlet.http.HttpServletRequest ; 13 import javax.servlet.http.HttpSession ; 14 15 import org.apache.commons.logging.Log; 16 import org.apache.commons.logging.LogFactory; 17 18 public class LogFilter implements Filter { 19 20 public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException , ServletException { 21 HttpServletRequest request = (HttpServletRequest ) servletRequest; 22 23 log.debug("request "+request.getRequestURL()); 24 25 Enumeration enumeration = request.getParameterNames(); 26 while (enumeration.hasMoreElements()) { 27 String paramName = (String ) enumeration.nextElement(); 28 log.debug("request parameter ["+paramName+"]="+request.getParameter(paramName)); 29 } 30 31 HttpSession session = request.getSession(); 32 enumeration = session.getAttributeNames(); 33 while (enumeration.hasMoreElements()) { 34 String attributeName = (String ) enumeration.nextElement(); 35 log.debug("session parameter ["+attributeName+"]="+session.getAttribute(attributeName)); 36 } 37 38 filterChain.doFilter(servletRequest, servletResponse); 39 } 40 41 public void init(FilterConfig filterConfig) throws ServletException { 42 } 43 44 public void destroy() { 45 } 46 47 private static final Log log = LogFactory.getLog(LogFilter.class); 48 } 49 | Popular Tags |