UrlRewriting with redirect=chain doesn't work
October 13, 2011 at 1:26 pm #18044
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 FrankOctober 14, 2011 at 5:40 am #21468
yes, you may be right. We hat a similar report from a user and I already created a ticket for this:
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.
ChristianOctober 14, 2011 at 10:47 am #21469
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.
PS: Shall I fix it for you?October 14, 2011 at 11:49 am #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.
ThanksOctober 14, 2011 at 2:32 pm #21471
I’ll check the GitHub-thing
Ciao FrankOctober 14, 2011 at 3:31 pm #21472
The GitHub-thing is too heavy for a oneliner. Just insert
in line 218 of PrettyFilter in branch 3.x.
Ciao FrankOctober 14, 2011 at 4:11 pm #21473
Lincoln Baxter IIIKeymaster
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
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.October 14, 2011 at 4:12 pm #21474
Lincoln Baxter IIIKeymaster
I should add, but doing the “Fork” as described above, you also get public credit for fixing thisOctober 15, 2011 at 7:57 am #21475
@lincoln: I didn’t know about the “Fork and Edit in Place” feature of GitHub! Thanks for the hint!October 17, 2011 at 7:47 am #21476
I’ll try the “Fork and Edit in Place” thing.
PS: the mapping is <rewrite match=”^/foo-(..)/$” substitute=”/api/feeds/atom/foo/$1″ redirect=”chain”/>October 17, 2011 at 8:48 am #21477
“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 FrankOctober 17, 2011 at 10:38 am #21478
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!
The forum ‘PrettyFaces Users’ is closed to new topics and replies.