I am developing a JEE5 web application, I need to write an http message and get the parameters, what is the best way?
In the beginning I tried with HttpRequest-> getQueryString, but it does not work with message parameters, then I wrote code that uses HttpRequest-> getParameterMap (see below)
Map<String,String[]> parametersName=theRequest.getParameterMap(); int count=0; for (String paramName : parametersName.keySet()) { String[] paramValues=parametersName.get(paramName); if(count>0) allParameter.append("&"); allParameter.append(paramName); allParameter.append("="); for (int i = 0; i < paramValues.length; i++) { allParameter.append(paramValues[i]); if(paramValues.length>1) allParameter.append(","); } count++; }
This works, but seems too complicated (compared to getQueryString) to work.
Is there a better / faster way?
source share