JSP HTTP Header Tool

HTTP Request

<%-- First, get the first line of the HTTP request --%>

<%= request.getMethod() %> <%= request.getRequestURI() %> <%= request.getProtocol() %>

Form Parameters Passed and their values

<%-- Get the names of the parameters passed form the form. Then walk through the list --%> <% java.util.Enumeration e2 = request.getParameterNames(); %> <% while (e2.hasMoreElements()){ %> <% String name = (String) e2.nextElement(); %> Param: <%= name %> Param Value(s): <% String[] dataList = request.getParameterValues(name); int count = dataList.length; int i = 0; while (i < count ){ %> <%= "[" + dataList[i] + "]" %> <% i++; } %>
<% } %>

Web Server Info

<%-- Each of these informational values can be obtained from the Request object --%> Web Server Name: <%= request.getServerName() %>
Web Server Port: <%= request.getServerPort() %>
Browser address: <%= request.getRemoteAddr() %>
Browser Host Name: <%= request.getRemoteHost() %>
Request URI: <%= request.getRequestURI() %>
Query Sting: <%= request.getQueryString() %>
Path Info: <%= request.getPathInfo() %>
Path Translated: <%= request.getPathTranslated() %>

HTTP Header (Not in order)

<%-- Like we did with the form values, get the header names pass in, and walk through the list --%> <% java.util.Enumeration e = request.getHeaderNames(); %>

<% while (e.hasMoreElements()){ %> <% String name = (String) e.nextElement(); %> <%= name %>: <%= request.getHeader(name) %>
<% } %>