Header Request is a request information that the user make request to the server. This will display the header information like local host name, request path, query generation. Here we made a program that will demonstrate the header information with as output on the web browser. Some packages like enumeration also declared for coding.
<%@ page import=”java.util.Enumeration” %>
<html>
<head>
<title><Header Request In JSP></title>
</head>
<body bgcolor=”#F3EDE9″>
<table border=”1″ align=”center” cellpadding=”2px” cellspacing=”2px align=”center”>
<tr>
<span><h2 align=”center”>Header’s Request info</h2></span>
</tr>
<%! Enumeration en, hdr;
String hdrname, hdrvl;
%>
<%
en = request.getHeaderNames();
while (en.hasMoreElements())
{
hdrname = (String) en.nextElement();
hdr = request.getHeaders(hdrname);
if(hdr != null)
{
while(hdr.hasMoreElements())
{
hdrvl= (String) hdr.nextElement();
}
}
%>
<tr>
<td align=”center” ><%= hdrname %></td>
<td align=”center”><%= hdrvl %></td>
</tr>
<%
}
%>
</table>
</body>
</html>