click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r949343 - /click/trunk/click/framework/src/org/apache/click/ClickServlet.java
Date Sat, 29 May 2010 06:22:03 GMT
Author: sabob
Date: Sat May 29 06:22:03 2010
New Revision: 949343

URL: http://svn.apache.org/viewvc?rev=949343&view=rev
Log:
Log request parameter name and values. CLK-676

Modified:
    click/trunk/click/framework/src/org/apache/click/ClickServlet.java

Modified: click/trunk/click/framework/src/org/apache/click/ClickServlet.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/ClickServlet.java?rev=949343&r1=949342&r2=949343&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/ClickServlet.java (original)
+++ click/trunk/click/framework/src/org/apache/click/ClickServlet.java Sat May 29 06:22:03
2010
@@ -928,26 +928,7 @@ public class ClickServlet extends HttpSe
 
         // Log request parameters
         if (logger.isTraceEnabled()) {
-            Map<String, Object> requestParams = new TreeMap<String, Object>();
-
-            Enumeration e = request.getParameterNames();
-            while (e.hasMoreElements()) {
-                String name = e.nextElement().toString();
-                String value = request.getParameter(name);
-                requestParams.put(name, value);
-            }
-
-            Iterator i = requestParams.entrySet().iterator();
-            while (i.hasNext()) {
-                Map.Entry entry = (Map.Entry) i.next();
-                String name = entry.getKey().toString();
-                String value = entry.getValue().toString();
-
-                String msg = "   request param: " + name + "="
-                    + ClickUtils.limitLength(value, 40);
-
-                logger.trace(msg);
-            }
+            logRequestParameters(request);
         }
 
         String path = Context.getThreadLocalContext().getResourcePath();
@@ -1804,4 +1785,53 @@ public class ClickServlet extends HttpSe
 
     }
 
+    // Private methods --------------------------------------------------------
+
+    /**
+     * Log the request parameter names and values.
+     *
+     * @param request the HTTP servlet request
+     */
+    private void logRequestParameters(HttpServletRequest request) {
+
+        Map<String, String[]> requestParams = new TreeMap<String, String[]>();
+
+        Enumeration e = request.getParameterNames();
+        while (e.hasMoreElements()) {
+            String name = e.nextElement().toString();
+            String[] values = request.getParameterValues(name);
+            requestParams.put(name, values);
+        }
+
+        Iterator it = requestParams.entrySet().iterator();
+        while (it.hasNext()) {
+            Map.Entry<String, String[]> entry =
+                (Map.Entry<String, String[]>) it.next();
+            String name = entry.getKey();
+            String[] values = entry.getValue();
+
+            HtmlStringBuffer buffer = new HtmlStringBuffer(40);
+            buffer.append("   request param: " + name + "=");
+
+            if (values == null) {
+                // ignore
+            } else if (values.length == 1) {
+
+                buffer.append(ClickUtils.limitLength(values[0], 40));
+            } else {
+
+                for (int i = 0; i < values.length; i++) {
+                    if (i == 0) {
+                        buffer.append('[');
+                    } else {
+                        buffer.append(", ");
+                    }
+                    buffer.append(ClickUtils.limitLength(values[i], 40));
+                }
+                buffer.append("]");
+            }
+
+            logger.trace(buffer.toString());
+        }
+    }
 }



Mime
View raw message