We help IT Professionals succeed at work.

How to display ALL Request/Response headers in JSP

gmahler5th
gmahler5th asked
on
2,093 Views
Last Modified: 2011-10-03
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.
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2016

Commented:
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

Author

Commented:
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?

Author

Commented:
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 %>
CERTIFIED EXPERT
Top Expert 2016

Commented:
Personally i wouldn't alter the code, but just use a proxy
CERTIFIED EXPERT
Top Expert 2007
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
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.

Author

Commented:
Wouldn't Enumeration e = request.getHeaderNames(); be the function to use, instead of enumeration of Params?
CERTIFIED EXPERT
Top Expert 2007

Commented:
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
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

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.