get Init Parameter Map from servlet FilterConfig - Java Servlet JSP

Java examples for Servlet JSP:Filter

Description

get Init Parameter Map from servlet FilterConfig

Demo Code


import java.util.*;
import javax.servlet.FilterConfig;

public class Main{
    @SuppressWarnings("unchecked")
    public static Map<String, String> getInitParameterMap(
            final FilterConfig fc) {
        if (fc == null)
            return null;

        final Map<String, String> m = new LinkedHashMap<String, String>();

        for (final Enumeration e = fc.getInitParameterNames(); e
                .hasMoreElements();) {/*from www. j  a va  2 s . c  o  m*/
            final String name = (String) e.nextElement();
            final String value = fc.getInitParameter(name);
            m.put(name, value);
        }

        return m;
    }
}

Related Tutorials