<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="oracle.portal.provider.v2.render.*" %>
<%@ page import="oracle.portal.provider.v2.PortletDefinition" %>
<%@ page import="oracle.portal.provider.v2.http.HttpCommonConstants" %>

<% 
    PortletRenderRequest portletRequest = (PortletRenderRequest)request.getAttribute(HttpCommonConstants.PORTLET_RENDER_REQUEST); 
    PortletRendererUtil.renderPortletHeader(portletRequest, out, null);
    
    // just render the portlet footer if the portlet is collapsed.
    RenderContext rc = portletRequest.getRenderContext();
    PortletDefinition pd = portletRequest.getPortletInstance().getPortletDefinition();
    if (rc.isCollapsed())
    {
        PortletRendererUtil.renderPortletFooter(portletRequest, out);
        return;
    }
%>


<h1> Request Information </h1>
<font size="2">
<table width=50% border="1">
<%if (portletRequest != null)
  {
   out.println("<tr><td>PortletReference: </td><td>" + portletRequest.getPortletReference().toString() + "</td></tr>");
   out.println("<tr><td>User: </td><td>" + portletRequest.getUser().getName() + "</td></tr>");
   out.println("<tr><td>Request URL: </td><td>" +
       portletRequest.getRequestURL() + "</td></tr>");
   if ( pd.getRewriteUrls() )
   {
       out.println("<tr><td>Page URL: </td><td>Not available with RewriteUrls</td></tr>");
       out.println("<tr><td>Design URL: </td><td>Not available with RewriteUrls</td></tr>");
       out.println("<tr><td>Back URL: </td><td>Not available with RewriteUrls</td></tr>");
   }
   else
   {
       out.println("<tr><td>Page URL: </td><td>" + rc.getPageURL() + "</td></tr>");
       out.println("<tr><td>Design URL: </td><td>" + rc.getDesignURL() + "</td></tr>");
       out.println("<tr><td>Back URL: </td><td>" + rc.getBackURL() + "</td></tr>");
   }
   out.println("<tr><td>Login URL: </td><td>" +
       portletRequest.getRenderContext().getLoginServerURL() + "</td></tr>");
   out.println("<tr><td>Title: </td><td>" +
       portletRequest.getRenderContext().hasTitle() + "</td></tr>");
   out.println("<tr><td>Border: </td><td>" +
       portletRequest.getRenderContext().hasBorder() + "</td></tr>");
  out.println("<tr><td>RenderMode: </td><td>" + PortletRendererUtil.getModeName(portletRequest.getMode()) + "</td></tr>");
  }
  else
  {
  out.println("<tr><td>No PortletRenderRequest </td><td></td></tr>");
  }
  %>
  <tr><td>JSP Request Method: </td><td><%=  request.getMethod() %></td></tr>
  <tr><td>Request URI: </td><td><%= request.getRequestURI()  %></td></tr>
  <tr><td>Request Protocol: </td><td><%= request.getProtocol() %></td></tr>
  <tr><td>Request scheme: </td><td><%= request.getScheme() %></td></tr>
  <tr><td>Servlet path: </td><td><%= request.getServletPath() %></td></tr>
  <tr><td>Path info: </td><td><%= request.getPathInfo() %></td></tr>
   <tr><td>Path translated: </td><td><%= request.getPathTranslated() %></td></tr>
   <tr><td>Query string: </td><td><%= request.getQueryString() %></td></tr>
   <%
  String attr;
  attr = (String) request.getAttribute("javax.servlet.include.request_uri");
  if (attr != null) {
    out.println("<tr><td>Included Request URI: </td><td>" + attr + "</td></tr>");
  }

  attr = (String) request.getAttribute("javax.servlet.include.servlet_path");
  if (attr != null) {
    out.println("<tr><td>Included Servlet path: </td><td>" + attr + "</td></tr>");
  }
  attr = (String) request.getAttribute("javax.servlet.include.path_info");
  if (attr != null) {
    out.println("<tr><td>Included Path info: </td><td>" + attr + "</td></tr>");
    attr = request.getRealPath(attr);
    if (attr != null) {
      out.println("<tr><td>Included path translated: </td><td>" + attr + "</td></tr>");
    }
  }
  attr = (String) request.getAttribute("javax.servlet.include.query_string");
  if (attr != null) {
    out.println("<tr><td>Included Query String: </td><td>" + attr + "</td></tr>");
  }

  java.util.Enumeration names = request.getParameterNames();
  while (names != null && names.hasMoreElements()) {
    String name = (String) names.nextElement();
    out.print("<tr><td>Parameter: " + name+"</td><td>");
    String[] values = request.getParameterValues(name);
    if (values != null) {
      String outStr = "  value: ";
      for (int j = 0; j < values.length; j++) {
        outStr = outStr + values[j] + ", ";
      }
      out.println(outStr.substring(0, outStr.length() - 2) + " </td></tr>");
    }
  }

  java.util.Enumeration cookieHeaders = request.getHeaders("Cookie");
  while (cookieHeaders != null && cookieHeaders.hasMoreElements())
  {
      out.print("<tr><td>Cookie Header:</td><td><pre>");
      out.print((String)cookieHeaders.nextElement());
      out.println("</pre></td></tr>");
  }

%>
<tr><td>Content length: </td><td><%= request.getContentLength() %></td></tr>
<tr><td>Content type: </td><td><%= request.getContentType() %></td></tr>
<tr><td>Server name: </td><td><%= request.getServerName() %></td></tr>
<tr><td>Server port: </td><td><%= request.getServerPort() %></td></tr>
<tr><td>Remote user: </td><td><%= request.getRemoteUser() %></td></tr>
<tr><td>Remote address: </td><td><%= request.getRemoteAddr() %></td></tr>
<tr><td>Remote host: </td><td><%= request.getRemoteHost() %></td></tr>
<tr><td>Authorization scheme: </td><td><%= request.getAuthType() %></td></tr> 
<tr><td>The browser you are using is </td><td><%= request.getHeader("User-Agent") %></td></tr>
</table>
</font>

<% 
    PortletRendererUtil.renderPortletFooter(portletRequest, out);
%>
