Print out HTTP Request Headers : HTTP Header « JSP « Java Tutorial

  Copyright (c) 2002 by Phil Hanna
  All rights reserved.
  You may study, use, modify, and distribute this
  software for any purpose provided that this
  copyright notice appears in all copies.
  This software is provided without warranty
  either expressed or implied.
<%@ page import="java.util.*" %>
      <jsp:include page="style.css" flush="true"/>
      <h1>HTTP Request Headers Received</h1>
      <table border="1" cellpadding="4" cellspacing="0">
         Enumeration eNames = request.getHeaderNames();
         while (eNames.hasMoreElements()) {
            String name = (String) eNames.nextElement();
            String value = normalize(request.getHeader(name));
         <tr><td><%= name %></td><td><%= value %></td></tr>
   private String normalize(String value)
      StringBuffer sb = new StringBuffer();
      for (int i = 0; i < value.length(); i++) {
         char c = value.charAt(i);
         if (c == ';')
      return sb.toString();

23.39.HTTP Header
23.39.1.Print out HTTP Request Headers
23.39.2.Get HTTP Header Information