<%@ page import="oracle.portal.provider.v2.render.*" %>
<%@ page import="oracle.portal.provider.v2.http.HttpCommonConstants" %>
<%@ page import="oracle.portal.utils.xml.v2.XMLUtil" %>
<%@ page import="java.util.Enumeration" %>

<% 
    PortletRenderRequest portletRequest = (PortletRenderRequest)request.getAttribute(HttpCommonConstants.PORTLET_RENDER_REQUEST); 
    PortletRendererUtil.renderPortletHeader(portletRequest, out, null);
%>

<SimpleText>
  <SimpleTitle>
    Portlet Request Information...
   </SimpleTitle>
</SimpleText>
<SimpleTable separator=" - ">
  <SimpleTableBody>
    <%
      if (portletRequest != null)
      {
        String portletReferenceString = XMLUtil.escapeXMLText(portletRequest.getPortletReference().toString());
        String userNameString         = XMLUtil.escapeXMLText(portletRequest.getUser().getName());
        String requestURLString       = XMLUtil.escapeXMLText(portletRequest.getRequestURL());
        String pageURLString          = XMLUtil.escapeXMLText(portletRequest.getRenderContext().getPageURL());
        String designURLString        = XMLUtil.escapeXMLText(portletRequest.getRenderContext().getDesignURL());
        String backURLString          = XMLUtil.escapeXMLText(portletRequest.getRenderContext().getBackURL());
        String loginURLString         = XMLUtil.escapeXMLText(portletRequest.getRenderContext().getLoginServerURL());
        String modeString             = XMLUtil.escapeXMLText(PortletRendererUtil.getModeName(portletRequest.getMode()));
    %>
        <SimpleRow>
          <SimpleCol><SimpleTextItem>
            PortletReference
          </SimpleTextItem></SimpleCol>
          <SimpleCol><SimpleTextItem>
            <%= portletReferenceString %>
          </SimpleTextItem></SimpleCol>
        </SimpleRow>
                    
        <SimpleRow>
          <SimpleCol><SimpleTextItem>
            User
          </SimpleTextItem></SimpleCol>
          <SimpleCol><SimpleTextItem>
            <%= userNameString %>
          </SimpleTextItem></SimpleCol>
        </SimpleRow>
        
        <!--
           This URL is generally vast, and so of limited practical value 
           displayed in a mobile device. So, for now, it is not displayed.
          
           <SimpleRow>
             <SimpleCol><SimpleTextItem>
               Request URL
             </SimpleTextItem></SimpleCol>
             <SimpleCol><SimpleTextItem>
             <%= requestURLString %>
             </SimpleTextItem></SimpleCol>
           </SimpleRow>
          -->
            
        <SimpleRow>
          <SimpleCol><SimpleTextItem>
            Page URL
          </SimpleTextItem></SimpleCol>
          <SimpleCol><SimpleTextItem>
            <%= pageURLString %>
          </SimpleTextItem></SimpleCol>
        </SimpleRow>
        
        <SimpleRow>
          <SimpleCol><SimpleTextItem>
            Design URL
          </SimpleTextItem></SimpleCol>
          <SimpleCol><SimpleTextItem>
            <%= designURLString %>
          </SimpleTextItem></SimpleCol>
        </SimpleRow>
            
        <SimpleRow>
          <SimpleCol><SimpleTextItem>
            Back URL
          </SimpleTextItem></SimpleCol>
          <SimpleCol><SimpleTextItem>
            <%= backURLString %>
          </SimpleTextItem></SimpleCol>
        </SimpleRow>
            
        <SimpleRow>
          <SimpleCol><SimpleTextItem>
            Login URL
          </SimpleTextItem></SimpleCol>
          <SimpleCol><SimpleTextItem>
            <%= loginURLString %>
          </SimpleTextItem></SimpleCol>
        </SimpleRow>
                                  
        <SimpleRow>
          <SimpleCol><SimpleTextItem>
            RenderMode
          </SimpleTextItem></SimpleCol>
          <SimpleCol><SimpleTextItem>
            <%= modeString %>
          </SimpleTextItem></SimpleCol>
        </SimpleRow>
    <%
      }
      else
      {
    %>
       <SimpleRow>
         <SimpleCol><SimpleTextItem>
           No PortletRenderRequest
         </SimpleTextItem></SimpleCol>
         <SimpleCol><SimpleTextItem>
         </SimpleTextItem></SimpleCol>
       </SimpleRow>");
    <%
      }
    %>
  </SimpleTableBody>
</SimpleTable>





<SimpleText>
  <SimpleTitle>
    HTTP Servlet Request Information...
   </SimpleTitle>
</SimpleText>
<SimpleTable separator=" - ">
  <SimpleTableBody>
    <SimpleRow>
      <SimpleCol><SimpleTextItem>JSP Request Method</SimpleTextItem></SimpleCol>
      <SimpleCol><SimpleTextItem><%=  request.getMethod() %></SimpleTextItem></SimpleCol>
    </SimpleRow>
    <SimpleRow>
      <SimpleCol><SimpleTextItem>Request URI</SimpleTextItem></SimpleCol>
      <SimpleCol><SimpleTextItem><%= XMLUtil.escapeXMLText(request.getRequestURI())  %></SimpleTextItem></SimpleCol>
    </SimpleRow>
    <SimpleRow>
      <SimpleCol><SimpleTextItem>Request Protocol</SimpleTextItem></SimpleCol>
      <SimpleCol><SimpleTextItem><%= request.getProtocol() %></SimpleTextItem></SimpleCol>
    </SimpleRow>
    <SimpleRow>
      <SimpleCol><SimpleTextItem>Request scheme</SimpleTextItem></SimpleCol>
      <SimpleCol><SimpleTextItem><%= request.getScheme() %></SimpleTextItem></SimpleCol>
    </SimpleRow>
    <SimpleRow>
      <SimpleCol><SimpleTextItem>Servlet path</SimpleTextItem></SimpleCol>
      <SimpleCol><SimpleTextItem><%= request.getServletPath() %></SimpleTextItem></SimpleCol>
    </SimpleRow>
    <SimpleRow>
      <SimpleCol><SimpleTextItem>Path info</SimpleTextItem></SimpleCol>
      <SimpleCol><SimpleTextItem><%= request.getPathInfo() %></SimpleTextItem></SimpleCol>
    </SimpleRow>
    <SimpleRow>
      <SimpleCol><SimpleTextItem>Path translated</SimpleTextItem></SimpleCol>
      <SimpleCol><SimpleTextItem><%= request.getPathTranslated() %></SimpleTextItem></SimpleCol>
    </SimpleRow>
    <SimpleRow>
      <SimpleCol><SimpleTextItem>Query string</SimpleTextItem></SimpleCol>
      <SimpleCol><SimpleTextItem><%= XMLUtil.escapeXMLText(request.getQueryString()) %></SimpleTextItem></SimpleCol>
    </SimpleRow>
  </SimpleTableBody>
</SimpleTable>




<SimpleText>
  <SimpleTitle>
    HTTP Servlet Request Parameters...
   </SimpleTitle>
</SimpleText>
<SimpleTable separator=" - ">
  <SimpleTableHeader>
    <SimpleCol>
      <SimpleTextItem>
        Name      
      </SimpleTextItem>
    </SimpleCol>
    <SimpleCol>
      <SimpleTextItem>
        Value 
      </SimpleTextItem>
    </SimpleCol>
  </SimpleTableHeader>
  <SimpleTableBody>
    <%
      java.util.Enumeration names = request.getParameterNames();
      while (names != null && names.hasMoreElements())
      {
        String name = (String) names.nextElement();
        out.print("<SimpleRow><SimpleCol><SimpleTextItem>");
        out.print(name);
        out.print("</SimpleTextItem></SimpleCol><SimpleCol><SimpleTextItem>");
        String[] values = request.getParameterValues(name);
        if (values != null)
        {
          String outStr = "";
          for (int j = 0; j < values.length; j++)
          {
            outStr = outStr + values[j] + ", ";
          }
          out.println(XMLUtil.escapeXMLText(outStr.substring(0, outStr.length() - 2)));
          out.print("</SimpleTextItem></SimpleCol></SimpleRow>");
        }
      }
    %>
  </SimpleTableBody>  
</SimpleTable>




<SimpleText>
  <SimpleTitle>
    HTTP Servlet Request Headers...
   </SimpleTitle>
</SimpleText>
<SimpleTable separator=" - ">
  <SimpleTableHeader>
    <SimpleCol>
      <SimpleTextItem>
        Name      
      </SimpleTextItem>
    </SimpleCol>
    <SimpleCol>
      <SimpleTextItem>
        Value 
      </SimpleTextItem>
    </SimpleCol>
  </SimpleTableHeader>
  <SimpleTableBody>
    <%
      names = request.getHeaderNames();
      while (names != null && names.hasMoreElements())
      {
        String name = (String) names.nextElement();
        out.print("<SimpleRow><SimpleCol><SimpleTextItem>");
        out.print(name);
        out.print("</SimpleTextItem></SimpleCol><SimpleCol><SimpleTextItem>");
        if ("Cookie".equalsIgnoreCase(name))
        {
          out.print("[See next table]");
        }
        else
        {
          Enumeration values = request.getHeaders(name);
          String outStr = "";
          while (values != null && values.hasMoreElements())
          {
            outStr = outStr + (String)values.nextElement() + ", ";
          }
          out.println(XMLUtil.escapeXMLText(outStr.substring(0, outStr.length() - 2)));
        }
        out.println("</SimpleTextItem></SimpleCol></SimpleRow>");
      }
    %>  
  </SimpleTableBody>
</SimpleTable>



<SimpleText>
  <SimpleTitle>
    HTTP Servlet Cookie Information...
   </SimpleTitle>
<%
  java.util.Enumeration cookieHeaders = request.getHeaders("Cookie");
  if (cookieHeaders != null && cookieHeaders.hasMoreElements())
  {
    while (cookieHeaders != null && cookieHeaders.hasMoreElements())
    {
      out.print("<SimpleTextItem>");
      out.print(XMLUtil.escapeXMLText((String)cookieHeaders.nextElement()));
      out.print("</SimpleTextItem>");
    }
  }
  else
  {
    out.print("<SimpleTextItem>No cookie information.</SimpleTextItem>");
  }
%>  
</SimpleText>

