we have a J2EE web application usig Spring MVC. We have a new requirement for our web application where we have to remove certain pre-defined characters from the user input. For example, let's say that the application should remove '<' from all the user inputs. I have come up with 2 approaches to meet this requirement :
JSP Level : identify each and every jsp which allows user input and then remove the characters by client side processing.
Servlet Filter : Use a filter and intercept the request object. Here I can use 1 of the following 2 approaches :
2.1 : Override the request.getParameter method and write the character removal logic inside it. Whenever this method is called, it will return the filtered result.
2.2 : At the filter level, scan the parameter map and filter the required characters. Then write a setParameter method and set the new values in the request parameter map.
Which approach do you suggest? Will the filter have any impact on the performance? If you can think of a better approach then please let me know.