Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8299021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:59:54+00:00 2026-06-08T15:59:54+00:00

I need to remove/modify some of HttpServletRequest parameters. I’m trying to do so by

  • 0

I need to remove/modify some of HttpServletRequest parameters. I’m trying to do so by using a Filter based on the question I posted a few days ago.

In the Filter, I’m trying to wrap the HttpServletRequest by inheriting the HttpServletRequestWrapper class as follows.

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<Object, Object> parameterMap = new HashMap<Object, Object>();
        Map originalParameterMap = super.getParameterMap();

        for (Object o : originalParameterMap.entrySet()) {
            Map.Entry<Object, Object> pairs = (Entry<Object, Object>) o;
            parameterMap.put(pairs.getKey(), pairs.getValue());
        }
        return parameterMap;  //Returning a modifiable ParameterMap.
    }
}

It’s an inner class within the Filter class. In the doFilter() method,

chain.doFilter(new FilteredRequest(request), (HttpServletResponse)response);

the constructor of the above class is being invoked (that wraps the request).


Now, I expect any of request parameters to modify/unset in my Spring MVC controller class. I’m trying to remove the parameter in the controller class as follows.

Map requestMap=request.getParameterMap();
requestMap.remove("txt_country_name");

Alternatively,

requestMap.put("txt_country_name", null);

Accordingly, the request parameter txt_country_name should be removed from the HttpServletRequest but it isn’t removed (nor it throws any exception like “No modifications are allowed to a locked ParameterMap“). What am I missing here? Am I following a wrong way?

By the way, Making/using a request attribute all the time through out the entire application doesn’t seem to be the best solution.

[I need to remove/modify request parameter within the Spring MVC controller class and not within the Filter itself]

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T15:59:57+00:00Added an answer on June 8, 2026 at 3:59 pm

    Your remove method modifies the mutable map returned by getParameterMap(). But the next call to getParameterMap() reconstructs a new mutable map containing all the parameters of the wrapped query.

    The mutable map should be constructed when the FilteredRequest is constructed, and it should be stored in an instance field.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Microsoft Activity Library Designer; For some reasons I need to use ListBox
i am using stored procedure and if i add/remove parameters (in the sproc) than
Got some basic problem again. I need to modify a function that previously returned
I need to use Jquery to modify divs on some certain pages that ends
I've been trying to figure out some layout update xml directives to add, remove
I have an ArrayList , and I need to filter it (only to remove
I'm using app.config file to store and read some parameters (sql server instance name,
I need to remove the border-top: 1px solid #202020; from .contact on my contact
I need to remove all classes of 'no-right-marg' on all #tips li elements. I
I need to remove break from a specific div , i know how to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.