UrlRewriting with redirect=chain doesn't work

Splash Forums PrettyFaces Users UrlRewriting with redirect=chain doesn't work

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

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #18044

    Frank Caputo
    Participant

    Hi,

    if we use redirect=chain in a rewrite rule, glassfish complains about too many dispatches:

    Exceeded maximum depth for nested request dispatches: 20

    It seems that PrettyFilter doesn’t flag the request with REWRITE_OCCURRED_KEY = true, because the flagging is done in the finally clause of PrettyFilter#rewrite. Shouldn’t it be flagged before calling req.getRequestDispatcher(newUrl).forward(req, resp)?

    Ciao Frank

    #21468

    Hey Frank,

    yes, you may be right. We hat a similar report from a user and I already created a ticket for this:

    http://code.google.com/p/prettyfaces/issues/detail?id=121

    Unfortunately I didn’t find time to look into this up till now. I’ll try to find some time on the weekend to check this.

    In the meantime you could work around this issue by modifying your rewrite rule. Usually the problem is caused by the fact that the rewritten URL also matches the pattern of the rewrite rule. In some cases you can simply change the pattern in a way that prevents this.

    Christian

    #21469

    Frank Caputo
    Participant

    Hi Christian,

    the second url doesn’t match after the forward, but you don’t get the url from the request but from the PrettyContext. That’s the problem.

    Ciao Frank

    PS: Shall I fix it for you?

    #21470

    Sure! We appreciate any kind of contribution. If you could provide a patch, I would try to review and apply it at the weekend. If you are familiar with GitHub, you could also create a pull request there.

    Thanks :)

    #21471

    Frank Caputo
    Participant

    I’ll check the GitHub-thing

    Ciao Frank

    #21472

    Frank Caputo
    Participant

    The GitHub-thing is too heavy for a oneliner. Just insert

    setRewriteOccurred(req);

    before

    req.getRequestDispatcher(newUrl).forward(req, resp);

    in line 218 of PrettyFilter in branch 3.x.

    Ciao Frank

    #21473

    Hey Frank,

    Thanks so much for figuring this out!

    Github should be pretty easy :) Just create an account, then go to PrettyFilter here (https://github.com/ocpsoft/prettyfaces/blob/3.x/core/src/main/java/com/ocpsoft/pretty/PrettyFilter.java) and click “Fork and Edit in Place”, then commit the change and it should create a patch request (pull request) for you automatically. You’ll just have to give it a name :)

    I’d love if you could write a test-case for this. Do you have time for that? Or could you provide us the configuration and URL that reproduces this?

    That would help us make sure we have eliminated this bug from all versions of PrettyFaces, both 3.x and 4.x :)

    Thanks!

    Also, if you want to try the prettyfaces 4.0.0-SNAPSHOT, this problem may not occur there. If it does, I’ll need to check why.

    #21474

    I should add, but doing the “Fork” as described above, you also get public credit for fixing this :)

    #21475

    @lincoln: I didn’t know about the “Fork and Edit in Place” feature of GitHub! Thanks for the hint! :)

    #21476

    Frank Caputo
    Participant

    Hi Lincoln,

    I’ll try the “Fork and Edit in Place” thing.

    Ciao Frank

    PS: the mapping is <rewrite match=”^/foo-(..)/$” substitute=”/api/feeds/atom/foo/$1″ redirect=”chain”/>

    #21477

    Frank Caputo
    Participant

    “Fork and Edit in Place” is done. Quite cool :-)

    Currently I have no time to test 4.0.0-SNAPSHOT nor to provide a test-case for the bug (it’s trivial or am I missing something?).

    When will you release 3.3.1 or 4.0? I’d like to contribute some performance-improvements, when I profile the next time (maybe in november), hopefully before you release :-)

    Ciao Frank

    #21478

    Hey Frank,

    thanks for the pull request. I’ll have a look at it soon. I already started to prepare a test case for the issue. I’ll check if my test passes with your patch! :)

    I think we will release 3.3.1 in the next 2-3 weeks. 4.0.0 will take longer. Performance improvements are always welcome! :)

    Thanks

    Christian

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

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

Comments are closed.