JSP Page that Displays all the Headers and Parameters

Here is a simple page that displays all the header information and parameter names and values using getHeaderNames and getParameterNames;

 1. <%@ page  import="java.util.*" %>
 2. <html>
 3. <head></head>
 4. <body>
 5. 
 6. <h3> Parameter Names </h3>
 7. <%  
 8.     String parameter;
 9.     Enumeration parameterNames;
10.     for( parameterNames = request.getParameterNames() ; parameterNames.hasMoreElements() ; ){
11.         parameter = parameterNames.nextElement().toString();
12.         out.println("[ "+parameter+" ] = "+request.getParameterValues(parameter)[0]+"<br/>");            
13.     }
14. %>
15. 
16. <h3>Header Names</h3>
17. <%  
18.     String header;
19.     Enumeration headerNames;
20.     for( headerNames = request.getHeaderNames() ; headerNames.hasMoreElements() ; ){
21.         header = headerNames.nextElement().toString();
22.         out.println("[ "+header+" ] = "+request.getHeader(header)+"<br/>");            
23.     }
24. %>
25. 
26. </body>
27. </html>
Hide line numbers

No comments: