how modify the response body with java filter? how modify the response body with java filter? json json

how modify the response body with java filter?


Thanks to the help of JBNizet, I found that the solution was to add the Content Lenght:

String newContent = "{ \"name\" : \"************r\" }";response.setContentLength(newContent .length());response.getWriter().write(newContent);


Actually, Following the answer above, you will get an error saying getWriter() has already been called for this response

So, you can simply just modify the last line like below:

String newContent = "{ \"name\" : \"************r\" }";response.setContentLength(newContent.length());response.getOutputStream().write(newContent.getBytes());