FileDocCategorySizeDatePackage
ParamSnoop.javaAPI DocExample1558Tue Feb 10 07:44:48 GMT 2004com.jspservletcookbook

ParamSnoop

public class ParamSnoop extends Object implements Filter

Fields Summary
private FilterConfig
config
Constructors Summary
public ParamSnoop()
Creates new ParamSnoop

    
Methods Summary
public voiddestroy()

        /*called before the Filter instance is removed 
        from service by the web container*/
    
public voiddoFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)

    
	    
        Map paramMap = request.getParameterMap();
        ServletContext context = config.getServletContext();
        /* use the ServletContext.log method to log 
        param names/values */
         context.log("doFilter called in: " + config.getFilterName() +  
          " on " + (new java.util.Date()));
        context.log("Snooping the parameters in request: " + 
            ((HttpServletRequest) request).getRequestURI());
            
         Iterator iter = paramMap.entrySet().iterator();
          while (iter.hasNext()){
             
             Map.Entry me = (Map.Entry) iter.next();
             context.log((String)me.getKey() + ": " + ((String[]) me.getValue())[0]);
          }

        chain.doFilter(request,response); 
		
    
public voidinit(javax.servlet.FilterConfig filterConfig)

    
        this.config = filterConfig;