This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Modifying Parameters with Filters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Modifying Parameters with Filters" Watch "Modifying Parameters with Filters" New topic

Modifying Parameters with Filters

Drew Lane
Ranch Hand

Joined: May 13, 2001
Posts: 296
I've been playing around with Filters trying to intercept/modify some parameters that get sent in by an HTML Form.

I can get the parameter with request.getParameter(), but how do I set it?

I can use request.getSession().setAttribute(), but I don't think this is the same thing.

I'm guessing I need to modify the request before calling doFilter().

Any help?


William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12753
You can't modify request parameters - what you have to do is make a custom HttpServletRequestWrapper extension. In your custom getParameter() and related methods, provide for catching the name of the parameter you want to "modify"
In the filter, replace the original request with the wrapped request.
I agree. Here's the link:
subject: Modifying Parameters with Filters
Similar Threads
Converting a Get Request into Post Request
Intercepting request parameters in JSP.
Servlet Chaining??
doubt regarding request parameters