code: public static void dumpRequest( ServletRequest request, PrintStream output )
      {
          if ( output == null )
          {
              output = System.err;
          }
  
          output.println( "*** ServletRequest " + request );
          
          if ( request instanceof HttpServletRequest )
          {
              output.println( "        uri = " + ( ( HttpServletRequest ) request ).getRequestURI() );
          }
  
          for ( Enumeration e = request.getParameterNames(); e.hasMoreElements(); )
          {
              String name = ( String ) e.nextElement();
              output.println( "            parameter " + name + " = " + request.getParameter( name ) );
          }
  
          for ( Enumeration e = request.getAttributeNames(); e.hasMoreElements(); )
          {
              String name = ( String ) e.nextElement();
              output.println( "            attribute " + name + " = " + request.getAttribute( name ) );
          }
  
          if ( request instanceof HttpServletRequest )
          {
              HttpSession session = ( ( HttpServletRequest ) request ).getSession( false );
              
              if ( session != null )
              {
                  for ( Enumeration e = session.getAttributeNames(); e.hasMoreElements(); )
                  {
                      String name = ( String ) e.nextElement();
                      output.println( "            session attribute " + name + " = " + session.getAttribute( name ) );
                  }
              }
          }
      }
docs: Print parameters and attributes in the given request.
  
  @param request the current HttpServletRequest.
  @param output a PrintStream to which to output request parameters and request/session
  attributes; if <code>null</null>, <code>System.err</code> is used.