This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Modifying Parameters with Filters

 
Drew Lane
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Thanks,

Drew
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic