FileDocCategorySizeDatePackage
RequestHeaderView.javaAPI DocExample1271Sat Feb 21 08:53:54 GMT 2004com.jspservletcookbook

RequestHeaderView

public class RequestHeaderView extends HttpServlet

Fields Summary
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

    
    //get an Enumeration of all the request header names
    Enumeration enum = request.getHeaderNames();
    
        
    //display 
      response.setContentType("text/html");
      java.io.PrintWriter out = response.getWriter();
      out.println("<html><head><title>Request Header View</title></head><body>");
      out.println("<h2>Request Headers</h2>");
      String header = null;
      
      while (enum.hasMoreElements()){
          header = (String) enum.nextElement();
          //getHeader returns null if a request header of that name does not exist in the request
         out.println( "<strong>"+header+"</strong>"+": "+request.getHeader(header)+"<br>" );
		 }
    
      out.println("</body></html>");
     
     
public voiddoPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

	    doGet(request,response);