I have a Java servlet and when I send it a POST request everything works just fine. The thing is that if send a GET request i want to make the same procedure as if it is a POST req, when I run request.getParameterMap() has size = 0.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
LinkedList<String> lErr = new LinkedList<String>();
System.out.printf("Request size: %d%n", request.getContentLength());
System.out.printf("Request method: %s%n", request.getMethod());
Map map = request.getParameterMap();
System.out.printf("ParameterMap size: %d%n", map.size());
}
What could the problem be?
Both POST and GET request have data in their body. I am sending it using form-data as getParameterMap() does not only supports query string but that also. POST request works just fine.