Is it possible to add/remove query parameters?

Splash Forums Rewrite Users Is it possible to add/remove query parameters?

This topic contains 6 replies, has 3 voices, and was last updated by  Christian Kaltepoth 7 years, 7 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #26274


    Is it possible to remove some query parameters in outgoing links?

    For example I have a link /some/page.xhtml?param=123&other=321
    If I rewrite it to /some/page/123 it still generates links with the remaining query parameters. So, in this case /some/page/123?other=321.

    Is it possible to remove that “other” parameter from generated links?


    Hey there. Yes, it is certainly possible to remove parameters from links. This should probably be done in an outbound rewrite rule, but I don’t think there’s a shorthand way of doing it. You’ll have to do it in plain old Java, something like this:

    .perform(new HttpOperation() {
       public void perform(HttpServletRewrite event, EvalutationContext context)
           Address address = event.getAddress();
           String newAddress = address.toString();
           newAddress = // Remove parameters from newAddress.

    Something like that. There are some Deprecated URLBuilder and QueryString builder types that may help you do this, but we will probably be replacing them with a betting API in the AddressBuilder API at some point in the future. This will work for now.



    Thanks for the quick reply!

    And is it possible to perform this for every rewrite rule (like a global rewrite rule?) or a batch of rules or does it have to be copied to every single one of them?

    P.S. PrettyFaces has quite good docs, it would be great if rewrite got better documentation. It seems like a good tool. πŸ™‚


    The rule Lincoln posted is already “global”. It is applied whenever there is a query parameter “other” in an outbound URL. See the when part of the rule:



    Ok, thanks.

    And what about these?

    The method exists(String) is undefined for the type QueryParameter

    The method setAddress(Address) is undefined for the type HttpServletRewrite



    Ok, I guess QueryParameter must be changed to RequestParameter. That fixes the first error and I found tests using it this way in GitHub.

    2nd problem about setAddress() remains. Any hints?


    I think you have to cast the event to HttpOutboundServletRewrite and then use setOutboundAddress if I remember correctly.

    And I think you have to use Query.parameterExists().

Viewing 7 posts - 1 through 7 (of 7 total)

The forum ‘Rewrite Users’ is closed to new topics and replies.

Comments are closed.