I want to loop through an enumeration containing all of the header names inside a java servlet. My code is as follows:
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<String> headerNames = ((HttpServletRequest) c).getHeaderNames();
}
}
Is this the correct syntax? How does one actually iterate over an enums values in Java? And specifically in this instance?
Thanks for your help, Marc