by Dinesh Thakur Category: Session

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>&lt;Header Request In JSP&gt;</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>

        Jsp headerRequest Example





About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.