This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

httpservletrequest setParameter()?

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a html form using post method. the url looks like
localhost/job.do?myquery=4_5
I want to change to
localhost/job.do?myqueryString=4&myqueryString=5

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?

Thanks
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic