import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class HeaderSnoop extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/plain"); PrintWriter out = res.getWriter(); out.println("Request Headers:"); out.println(); Enumeration enum = req.getHeaderNames(); while (enum.hasMoreElements()) { String name = (String) enum.nextElement(); String value = req.getHeader(name); if (value != null) { out.println(name + ": " + value); } } } }