This week's book giveaway is in the JavaScript forum.
We're giving away four copies of JavaScript Promises Essentials and have Rami Sarieddine on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Remove one parameter from the query string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Remove one parameter from the query string" Watch "Remove one parameter from the query string" New topic
Author

Remove one parameter from the query string

Nalini Nagarathinam
Greenhorn

Joined: Jun 13, 2010
Posts: 16
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?


Nalini Nagarathinam
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61594
    
  67

For what purpose? The query string has already been submitted, what use is there in modifying it?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nalini Nagarathinam
Greenhorn

Joined: Jun 13, 2010
Posts: 16
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

Joined: Jan 20, 2010
Posts: 247

use replace method of string .

for example.




Good luck!!
A small leak can sink a Gigantic ship.>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61594
    
  67

Moved to Java beginner.
Nalini Nagarathinam
Greenhorn

Joined: Jun 13, 2010
Posts: 16
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

Joined: Jan 20, 2010
Posts: 247

ok great..

second one looks more appropriate.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Remove one parameter from the query string