title: Modifying HttpServletRequest parameters with a Servlet Filter doesn't seem to work
body: <p>I need to remove/modify some of <code>HttpServletRequest</code> parameters. I'm trying to do so by using a <code>Filter</code> based on the <a href="https://stackoverflow.com/q/11304100/1391249">question</a> I posted a few days ago.</p>
  
  <p>In the <code>Filter</code>, I'm trying to wrap the <code>HttpServletRequest</code> by inheriting the <code>HttpServletRequestWrapper</code> class as follows.</p>
  
  <pre><code>private final static class FilteredRequest extends HttpServletRequestWrapper {
  
      public FilteredRequest(ServletRequest request) {
          super((HttpServletRequest) request);
      }
  
      @Override
      public String getParameter(String paramName) {
          return super.getParameter(paramName);
      }
  
      @Override
      public String[] getParameterValues(String paramName) {
          return super.getParameterValues(paramName);
      }
  
      @Override
      public Map getParameterMap() {
          Map&lt;Object, Object&gt; parameterMap = new HashMap&lt;Object, Object&gt;();
          Map originalParameterMap = super.getParameterMap();
  
          for (Object o : originalParameterMap.entrySet()) {
              Map.Entry&lt;Object, Object&gt; pairs = (Entry&lt;Object, Object&gt;) o;
              parameterMap.put(pairs.getKey(), pairs.getValue());
          }
          return parameterMap;  //Returning a modifiable ParameterMap.
      }
  }
  </code></pre>
  
  <p>It's an inner class within the <code>Filter</code> class. In the <code>doFilter()</code> method,</p>
  
  <pre><code>chain.doFilter(new FilteredRequest(request), (HttpServletResponse)response);
  </code></pre>
  
  <p>the constructor of the above class is being invoked (that wraps the request).</p>
  
  <hr>
  
  <p>Now, I expect any of request parameters to modify/unset in <strong>my Spring MVC controller class</strong>. I'm trying to remove the parameter in the controller class as follows.</p>
  
  <pre><code>Map requestMap=request.getParameterMap();
  requestMap.remove("txt_country_name");
  </code></pre>
  
  <p>Alternatively, </p>
  
  <pre><code>requestMap.put("txt_country_name", null);
  </code></pre>
  
  <p>Accordingly, the request parameter <code>txt_country_name</code> should be removed from the <code>HttpServletRequest</code> but it isn't removed (nor it throws any exception like "<em>No modifications are allowed to a locked ParameterMap</em>"). What am I missing here? Am I following a wrong way?</p>
  
  <p>By the way, <em>Making/using a request attribute all the time through out the entire application doesn't seem to be the best solution</em>.</p>
  
  <p>[I need to remove/modify request parameter <strong>within the Spring MVC controller class</strong> and not within the <code>Filter</code> itself]</p>