Link to home
Start Free TrialLog in
Avatar of gmahler5th
gmahler5thFlag for United States of America

asked on

How to display ALL Request/Response headers in JSP

What JSP code would I use if I want ALL of the Request and Response headers to be displayed on the page?  In other words, just looking to get a dump of all headers and to display them on the page for debugging. Running Apache, WebLogic and RHEL.
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

You would be better off using a proxy for debugging. There's a pretty good one written in Java called 'Charles'

For the response. You can use wget in debug mode

man wget
Avatar of gmahler5th

ASKER

I just want to see the code, so I can put it in a JSP and have them ALL display.

is it required to put Apache in Debug mode?
For example, in ASP code I use the following.  How would I do the same thing in JSP?

<% For Each item In Request.ServerVariables %>
     
                <span class="bgcolorsmallcapsnoborder"><%= item %></strong>: &nbsp;</span>
       
                <span  class="bodyfine"><%= Request.ServerVariables(item) %></span><br /><br />
     
      <% Next %>
Personally i wouldn't alter the code, but just use a proxy
ASKER CERTIFIED SOLUTION
Avatar of mrcoffee365
mrcoffee365
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
CEH, it is specifically required to test authz rules on a URL, and I need the vars to be displayed on this page only.

MrCoffee, does that code also display the server variables such as header vars?  I.e. just want to be sure that request.getParameter will have server variables, and not just URL parameters.

thanks.
Wouldn't Enumeration e = request.getHeaderNames(); be the function to use, instead of enumeration of Params?
gmahler5th - you're right.  I misread the request, and assumed that they wanted request parameters.

The same code, with getHeaderNames() and individual getHeader(pName) would get the header names and values.

The real answer is to look at the API and get the information you want from the HttpServletRequest:
http://java.sun.com/products/servlet/2.3/javadoc/index.html
Avatar of Ajay-Singh
Ajay-Singh

If you are using tomcat as web-container, you can use request dumper value.
More, http://tomcat.apache.org/tomcat-5.0-doc/config/valve.html