import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class RequestHeaderView extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
//get an Enumeration of all the request header names
Enumeration e = request.getHeaderNames();
//display
response.setContentType("text/html");
java.io.PrintWriter out = response.getWriter();
out.println("Request Header View");
out.println("Request Headers
");
String header = null;
while (e.hasMoreElements()) {
header = (String) e.nextElement();
//getHeader returns null if a request header of that name does not
// exist in the request
out.println("" + header + "" + ": "
+ request.getHeader(header) + "
");
}
out.println("");
} //end doGet
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
doGet(request, response);
}
}