File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes httpservletrequest setParameter()? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "httpservletrequest setParameter()?" Watch "httpservletrequest setParameter()?" New topic

httpservletrequest setParameter()?

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
I have a html form using post method. the url looks like
I want to change to

I want to do it this in the server side. I want to do a filter, if server finds the "myquery", then split string, add it back to URL , then forward.

Now, the problem is, we don't have options to control parameter, for example, setParameter().

How to solve it?

Carl Trusiak

Joined: Jun 13, 2000
Posts: 3340
In your filter create an HttpServletRequestWrapper

In your wrapper have most methods simply delegate to the wrapped request, add the method addParameter, and override the getParameter type methods as necessary to correctly give values back. Then when you call the doFilter method, pass the wrapper instead of the original request.

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
I agree. Here's the link:
subject: httpservletrequest setParameter()?
It's not a secret anymore!