-1

I have a request which is already coming from a doFilter method, Now I want to clean the parameters of that request that is free from special characters. After changing the parameters I want to set that parameter and pass it to the same request.

I have tried request.setAttribute till now, that solves the problem but it doesn't sanitizes the parameter i.e: the parameter is not changed.

I have tried many things till now,

  • Some posts in stackoverflow, but that hasn't helped

How can I clean the parameter and again set it to request wrapper and then pass it to doFilter.

Ashutosh Anand
  • 169
  • 3
  • 3
  • 14

1 Answers1

0

You cannot clean the parameters of that request but you can wrap it with a subclass of HttpServletRequestWrapper that you can pass to the next filter in chain. Original request is passed in constructor.

The wrapper must have as a field a modifiable map initialized with the parameters of the other request (minus those you need to remove) and must extend all the parameters related methods in order to use that map for the implementation (and not those of the original request)

An example with similar requirements: https://stackoverflow.com/a/1422202/1536382

Community
  • 1
  • 1
Testo Testini
  • 2,200
  • 18
  • 29