• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Remove one parameter from the query string

 
Nalini Nagarathinam
Greenhorn
Posts: 16
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a requirement, for that i need to remove the particular parameter from the query String.

Let say,



I want to remove the foo parameter from the above query string. Foo parameter can be at anywhere in the string(start, end of the string)

Shall i use regex to find the pattern or any other way to remove it in servlet?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For what purpose? The query string has already been submitted, what use is there in modifying it?
 
Nalini Nagarathinam
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thank you for your reply

I want to remove one parameter and add a new parameter and post it as the POST request.
This is my requirement.
 
Raza Mohd
Ranch Hand
Posts: 247
Java MyEclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use replace method of string .

for example.



 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to Java beginner.
 
Nalini Nagarathinam
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Wht you have suggestted is fine for to replace the string foo.

But i need to replace the parameter foo=value.

My Solution:
1) we can write the pattern to find the string and replace
2) Use request.getParameterValues& getParameterNames to the parameters, loop through the parameters and remove it.

Thanks,
 
Raza Mohd
Ranch Hand
Posts: 247
Java MyEclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok great..

second one looks more appropriate.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic