<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>  
<%@ page import="gov.va.med.fw.util.StringUtils" %>
<%! Enumeration e = null; 

private String format(Object o)
{
	String str = "";
	if (o instanceof Collection) 
	{
		str = StringUtils.stringFor((Collection) o, "Collection");
	}
	else if (o instanceof Map)
	{
		str = StringUtils.stringFor((Map)o, "Map");
	}		
	else if (o instanceof Object[])
	{
		Object[] os = (Object[]) o;
		StringBuffer sb = new StringBuffer();
		sb.append("Array[");
		for (int i=0; i < os.length; i++)
		{
			sb.append(format(os[i]));
			
			if (i < os.length)
			{
				sb.append(", ");
			}
		}
		sb.append("]");
		str = sb.toString();
	}
	else
	{
		str = String.valueOf(o);
	}
	return str;
}

%>

<br>
<br>
<br>
<hr>
<font face="Verdana" size="1">Request class: <%=request.getClass().getName()%></font>
<br>
<font face="Verdana" size="1"><b>Request Parameters</b></font>
<%
e = request.getParameterNames();


if (!e.hasMoreElements())
{
  %>
  <font face="Verdana" size="1">: none<br></font>
  <%
}
else 
{
  %>
  <table border="2" width="800">
  <%
  do 
  {
    String attr = (String)e.nextElement();
	  String[] values = request.getParameterValues(attr);
	  %><tr><td width="200"><font face="Verdana" size="1"><%=attr%></font></td>
	  <td width="600"><font face="Verdana" size="1">
	      <%
	      if (values != null)
	      {
	          for (int i=0; i<values.length; i++)
	          {
	              %><%=values[i]%><br><%
	          }
	      }
  	    
	      %>
	    </font></td></tr><%
  } while (e.hasMoreElements());
  %>
  </table>
  <%
}
%>

<font face="Verdana" size="1"><br><b>Request Attributes</b></font>
<table border="2" width="800">
<%
e = request.getAttributeNames();
while (e.hasMoreElements())
{
      String attr = (String)e.nextElement();
	Object value = request.getAttribute(attr);
	%><tr><td width="200"><font face="Verdana" size="1"><%=attr%></font></td>
	<td width="600"><font face="Verdana" size="1"><%=value%></font></td></tr><%
}
%>
</table>

<font face="Verdana" size="1"><br><b>Session Attributes</b></font>

<table border="2" width="800">
<%
e = session.getAttributeNames();
while (e.hasMoreElements())
{
      String attr = (String)e.nextElement();
	Object value = session.getAttribute(attr);
	%><tr><td><font face="Verdana" size="1"><%=attr%></font></td><td><font face="Verdana" size="1"><%=value%></font></td></tr><%
}
%>
</table>

<font face="Verdana" size="1"><br><b>Servlet Context Attributes</b></font>
<table border="2" width="800">
<%
e = application.getAttributeNames();
while (e.hasMoreElements())
{
      String attr = (String)e.nextElement();
	Object value = application.getAttribute(attr);
	%><tr><td><font face="Verdana" size="1"><%=attr%></font></td><td><font face="Verdana" size="1"><%=value%></font></td></tr><%
}
%>
</table>

<font face="Verdana" size="1"><br><b>HttpServletRequest HTTP Header</b></font>
<table border="2" width="800">
<%
e = request.getHeaderNames();
while (e.hasMoreElements())
{
      String attr = (String)e.nextElement();
	Enumeration ve = request.getHeaders(attr);
	%><tr><td><font face="Verdana" size="1"><%=attr%></font></td><td><font face="Verdana" size="1"><%

      while (ve.hasMoreElements())
	{
		%><%=ve.nextElement()%><br><%
	}

	%></font></td></tr><%
}
%>
</table>

<font face="Verdana" size="1"><br><b>Page Context Attributes</b></font>
<table border="2" width="800">
<%
e = pageContext.getAttributeNamesInScope(PageContext.PAGE_SCOPE);
while (e.hasMoreElements())
{
      String attr = (String)e.nextElement();
	Object value = pageContext.getAttribute(attr);
	%><tr><td width="200"><font face="Verdana" size="1"><%=attr%></font></td>
	<td width="600"><font face="Verdana" size="1"><%=value%></font></td></tr><%
}
%>
</table>
