<%@ VERSION="0.92" %>
<%@ LANGUAGE="java" %>

<%@ IMPORT="java.util.Enumeration" %>
<%@ IMPORT="javax.servlet.http.HttpUtils" %>

<HTML>
<HEAD>
  <TITLE>JSP Snoop Page</TITLE>
</HEAD>
<BODY>

<H1>JSP Snoop Page</H1>

<H2>Request information</H2>

<TABLE>
<TR>
  <TH align=right>Requested URL:</TH>
  <TD><%= HttpUtils.getRequestURL(servletrequest) %></TD>
</TR>
<TR>
  <TH align=right>Request method:</TH>
  <TD><%= servletrequest.getMethod() %></TD>
</TR>
<TR>
  <TH align=right>Request URI:</TH>
  <TD><%= servletrequest.getRequestURI() %></TD>
</TR>
<TR>
  <TH align=right>Request protocol:</TH>
  <TD><%= servletrequest.getProtocol() %></TD>
</TR>
<TR>
  <TH align=right>Servlet path:</TH>
  <TD><%= servletrequest.getServletPath() %></TD>
</TR>
<TR>
  <TH align=right>Path info:</TH>
  <TD><%= servletrequest.getPathInfo() %></TD>
</TR>
<TR>
  <TH align=right>Path translated:</TH>
  <TD><%= servletrequest.getPathTranslated() %></TD>
</TR>
<TR>
  <TH align=right>Query string:</TH>
  <TD><%= servletrequest.getQueryString() %></TD>
</TR>
<TR>
  <TH align=right>Content length:</TH>
  <TD><%= servletrequest.getContentLength() %></TD>
</TR>
<TR>
  <TH align=right>Content type:</TH>
  <TD><%= servletrequest.getContentType() %></TD>
<TR>
<TR>
  <TH align=right>Server name:</TH>
  <TD><%= servletrequest.getServerName() %></TD>
<TR>
<TR>
  <TH align=right>Server port:</TH>
  <TD><%= servletrequest.getServerPort() %></TD>
<TR>
<TR>
  <TH align=right>Remote user:</TH>
  <TD><%= servletrequest.getRemoteUser() %></TD>
<TR>
<TR>
  <TH align=right>Remote address:</TH>
  <TD><%= servletrequest.getRemoteAddr() %></TD>
<TR>
<TR>
  <TH align=right>Remote host:</TH>
  <TD><%= servletrequest.getRemoteHost() %></TD>
<TR>
<TR>
  <TH align=right>Authorization scheme:</TH>
  <TD><%= servletrequest.getAuthType() %></TD>
<TR>
</TABLE>

<%
  Enumeration e = servletrequest.getHeaderNames();

  if (e != null && e.hasMoreElements())
  {
%>
<H2>Request headers</H2>

<TABLE>
<TR>
  <TH align=left>Header:</TH>
  <TH align=left>Value:</TH>
</TR>
<%
    while(e.hasMoreElements())
    {
      String k = (String) e.nextElement();
%>
<TR>
  <TD><%= k %></TD>
  <TD><%= servletrequest.getHeader(k) %></TD>
</TR>
<%
    }
%>
</TABLE>
<%
  }
%>


<%
  e = servletrequest.getParameterNames();
  if (e != null && e.hasMoreElements())
  {
%>
<H2>Servlet parameters</H2>
<TABLE>
<TR valign=top>
  <TH align=left>Parameter:</TH>
  <TH align=left>Value:</TH>
  <TH align=left>Multiple values:</TH>
</TR>
<%
    while (e.hasMoreElements())
    {
      String k = (String) e.nextElement();
      String val = servletrequest.getParameter(k);
      String vals[] = servletrequest.getParameterValues(k);
%>
<TR valign=top>
  <TD><%= k %></TD>
  <TD><%= val %></TD>
  <TD><%
      for (int i = 0; i < vals.length; i++)
      {
        if (i > 0)
	{
          out.print("<BR>");
	}

        out.print(vals[i]);
      }
    %></TD>
</TR>
<%
    }
%>
</TABLE>
<%
  }
%>

</BODY>
</HTML>
