The following code example demonstrates How to Display HTTP Header Information Using JSP.

Here is an example of a JSP program that displays HTTP header information.

<%@ page language="java" contentType="text/html; charset=UTF-8"
<!DOCTYPE html>
<meta charset="UTF-8">
<title>HTTP Header Information</title>
  <h1>HTTP Header Information</h1>
      <th>Header Name</th>
      <th>Header Value</th>
      Enumeration<String> headerNames = request.getHeaderNames();
      while (headerNames.hasMoreElements()) {
        String headerName = headerNames.nextElement();
        String headerValue = request.getHeader(headerName);
      <td><%= headerName %></td>
      <td><%= headerValue %></td>

In this example, the JSP page uses a scriptlet to retrieve the HTTP header information from the request object and display it in a table. The getHeaderNames method of the request object returns an enumeration of header names, and the getHeader method is used to retrieve the value of each header. The header names and values are displayed in a table using a loop.

Further Reading

Understanding Enterprise Java Beans

Java Practice Exercise