@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
StringWriter writer = new StringWriter();
IOUtils.copy(request.getInputStream(), writer, "UTF-8");
rawRequest = writer.toString();
System.out.println("raw Request :" + rawRequest);
chain.doFilter(req, res);
}
When I run this, I get the raw Request string in proper format, but when I try to get this raw Request anywhere outside the doFilter method, it returns null.
Is there a way I can get this String outside the doFilter method as well. I tried passing this String to a new method but nothing works.