A servlet can examine all its init parameters using getInitParameterNames();

    public Enumeration ServletConfig.getInitParameterNames()

The GenericServlet class also makes this method directly available to servlets to servlets. Following servlet prints the name and value for all of its init parameters.

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

public class DemoInitSnoop extends GenericServlet{

    public void service(ServletRequest req , ServletResponse res)
          throws ServletException,IOException{

      res.setContentType("text/plain");
      PrintWriter out= res.getWriter();
      out.println("Init Parameter");

      Enumeration enum = getInitParameterNames();
      while (enum.hasMoreElements()){
        String name = (String)enum.nextElement();
        out.println(name + "." + getInitParameter(name));
      }
  }
}