I need to encode the URL in order to prevent security threat. I don't have to encode the complete URL, I just have to encode the value for query string. Can someone help me on how to encode only the values of query string parameters and change it in the URL itself using java. I am planning to do this in filter. Please help.