Display web request attributes and parameters

less than 1 minute read

To display the list of attributes and parameters that are linked to a http request in a jsp page.

<pre name="code" class="java">
Enumeration attrEnum = request.getAttributeNames();
while(attrEnum.hasMoreElements())
{
Object attr = attrEnum.nextElement();
System.out.println(“Attr “+(String)attr+” : “+request.getAttribute((String)attr));
}

Enumeration paramEnum = request.getParameterNames();
while(paramEnum.hasMoreElements())
{
Object attr = paramEnum.nextElement();
System.out.println(“Param “+(String)attr+” : “+request.getParameter((String)attr));
}
</pre>

Categories:

Updated:

Leave a Comment