Displaying All Headers
public class Headers extends HttpServlet {
public void doPost(HttpServletRequest req,
HttpServletResponse resp) {
resp.setContentType(text/html) ;
PrintWriter out = resp.getWriter() ;
out.println(<html><head></head><body>) ;
Enumeration headers req.getHeaderNames() ;
while(headers.hasMoreElements()) {
String name = (String) headers.nextElement() ;
out.println(name + <br> +
req.getHeader(name) + <br><br>) ;
out.println(</body></html>) ;