title: Loop through an Enumeration containing Header Names in Java Servlet
body: <p>I want to loop through an enumeration containing all of the header names inside a java servlet.  My code is as follows:</p>
  
  <pre><code>public class ServletParameterServlet extends HttpServlet
  {
      @Override
      protected void doGet(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException
      {
          ServletConfig c = this.getServletConfig();
          PrintWriter writer = response.getWriter();
  
          writer.append("database: ").append(c.getInitParameter("database"))
                .append(", server: ").append(c.getInitParameter("server"));
  
         Enumeration&lt;String&gt; headerNames = ((HttpServletRequest) c).getHeaderNames();
  
  
      }
  }
  </code></pre>
  
  <p>Is this the correct syntax?  How does one actually iterate over an enums values in Java?  And specifically in this instance?</p>
  
  <p>Thanks for your help,
  Marc</p>