KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > webapp > filter > LogFilter


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