1

I'm incrementally migrating our application servlets from web.xml to Guice servlet module and encountered problem with UrlRewrite filter (tuckey.org/urlrewrite/‎). It does not process servlets registered in Guice module. If I register both servlet and filter in web.xml everything works fine, but If I try to register them in Guice module - doesnt. Has someone encountered similar problem ?

Here are some excerpts from code :

1) Guice configuration module.

public class ServletConfigurationModule extends ServletModule {

@Override
protected void configureServlets() {

    bind(UrlRewriteFilter.class).in(Singleton.class);

    Map<String, String> urlRewriteParams = new HashMap<>();
    urlRewriteParams.put("confReloadCheckInterval", "60");
    urlRewriteParams.put("statusEnabled", "false");

    filter("/*").through(UrlRewriteFilter.class, urlRewriteParams);

    serve("/account").with(Account.class);

2) urlrewrite.xml contents

    <rule>
       <from>/affiliate-activation</from>
       <to>/account?do=affiliate&amp;trg=5</to>
    </rule>

When I try to open url myhost/affiliate-activation I get 404 HTTP error.

S.R.
  • 21
  • 2
  • I suppose that posting sample code is always welcome and enables better understanding of the problem. – Opal Apr 08 '14 at 19:21
  • Everything seems perfectly fine. I'm afraid that this filter may simply won't work with guice. – Opal Apr 08 '14 at 20:29

1 Answers1

0

I hope I've worked this out. Here You can find a repo with an example. Clone the repo and execute gradle jettyRun. You can test the application with browser. Feel free to ask any questions and share ideas. Basically the urlrewrite.xml was changed.

Opal
  • 81,889
  • 28
  • 189
  • 210
  • Hi, thanks for Your help, the solution worked, but is there any way to not overwrite the original (in our case "affiliate-activation") URL with redirected URL (/account?do=affiliate&trg=5) in browser ? In other words the original URL should stay the same in browser window. – S.R. Apr 09 '14 at 07:31