Showing posts with label HttpServletRequest. Show all posts
Showing posts with label HttpServletRequest. Show all posts

Friday, 26 July 2013

How to get parameter map from http request in java.

How to get parameter map from httpServlet request in java.

public static Map<String, String> getRequestMap(HttpServlet request){
         Map<String, String> r = new HashMap<String, String>();
         for (Map.Entry<String, String[]> entry: request.getParameterMap().entrySet()){
           String[] value = entry.getValue();
           if (value !=null && value .length>0) r.put(entry.getKey(), value[0]);
         }
         return r;

       }