The best way (and quick) to register request / send http request parameters

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?

+4
source share
2 answers

All HTTP (and application servers) support access.log, a log file that stores HTTP requests and responses. Just set it up.

+2
source

You can also do it like this:

 Enumeration parms = request.getHeaderNames(); String parmname; String parmval; while (parms.hasMoreElements()) { parmname = (String)parms.nextElement(); parmval = request.getHeader(parmname); Logger.log(parmname + " - " + parmval); } 
0
source

Source: https://habr.com/ru/post/1444137/


All Articles