Pages

Saturday 20 February 2016

Print all the request parameters map in java

This piece of utility code would print all the key-value pairs in the request object.

 Map<String, String[]> params = request.getParameterMap();

 Iterator<String> i = params.keySet().iterator();



 while ( i.hasNext() ){

 String key = (String) i.next();

 String value = ((String[]) params.get( key ))[ 0 ];

 System.out.println("Requst Params Key: ["+key+"] - Val: ["+value+"]");

 }


Here in the above code "request" is an object of "HttpServletRequest".

Wednesday 10 February 2016