request.getHeaderNames(); request.getCookies();

How to get and print the headers and cookies in JSP page.

 

<H1>Reading Header Information</H1>
        Here are the request headers and their data:
        <BR>
        <% java.util.Enumeration names = request.getHeaderNames();
        while(names.hasMoreElements()){
            String name = (String) names.nextElement();
            out.println(name + ":<BR>" + request.getHeader(name) + "<BR><BR>");
        }
        %>
        
        
        <%
        Cookie cookies[] = request.getCookies();

		out.println("<table>");
		for (int i=0; i<cookies.length; i++) {
			out.println("<tr>");
			out.println("<td>" + cookies[i].getName() + "</td>");
			out.println("<td>" + cookies[i].getDomain() + "</td>");
			out.println("<td>" + cookies[i].getPath() + "</td>");
			out.println("<td>" + cookies[i].getValue() + "</td>");
			out.println("<td>" + cookies[i].getMaxAge() + "</td>");
			out.println("</tr>");
		}
		out.println("</table>");
		%>
		
 

 

你可能感兴趣的:(request header,request cookie)