I\'ve got a bug involving httprequest, which happens sometimes, so I\'d like to log HttpGet and HttpPost request\'s content when that happens.
So, let\'s say, I create H
You can print the request type using:
request.getMethod();
You can print all the headers as mentioned here:
Enumeration headerNames = request.getHeaderNames();
while(headerNames.hasMoreElements()) {
String headerName = headerNames.nextElement();
System.out.println("Header Name - " + headerName + ", Value - " + request.getHeader(headerName));
}
To print all the request params, use this:
Enumeration params = request.getParameterNames();
while(params.hasMoreElements()){
String paramName = params.nextElement();
System.out.println("Parameter Name - "+paramName+", Value - "+request.getParameter(paramName));
}
request
is the instance of HttpServletRequest
You can beautify the outputs as you desire.