Get rid of the auto Servlet redirect in case of 404

Hi xwikiiers,

When any endpoint in XWiki produce a 404, it gets redirected (it’s a Servlet internal redirect, not a full HTTP redirect) to /bin/view/Main/DocumentDoesNotExist.

While it makes sense for a page, it actually generally cause problems for other endpoints:

  • they cannot send back custom content (unless they force a flush, but then it will produce warnings when DocumentDoesNotExist is executed)
  • it also causes quite a few problems in some endpoints for which not everything is properly initialized for /bin/view/Main/DocumentDoesNotExist to work (which is actually most endpoints)
  • it can cause major performance problems when a lot of queries are targeting not existing (web, rest, etc.) resources since it’s a lot more expensive than just returning a simple HTTP 404 (with sometime a very small custom content)

I actually noticed that `XWikiAction` have a “native” error handling which produce the exact same end result by default (executing “docdoesnotexist” template) so mostly the same thing is done twice. It also has the added bonus that it’s done in a more accurate context (the page which does not exist) and it’s of course also much better for performance to do that only once.

So I propose to simply get rid of the global 404 redirect in web.xml.

The only downside is that it won’t be possible to customize that using a Main.DocumentDoesNotExist page anymore (which is a regression). But you can still very easily customize the display of a not existing pages, through a wiki template for docdoesnotexist.vm.

  1. Remove that in master
  2. Remove that also in LTS branches

WDYT ?

Here is my +1 for 1. and +0 for 2.. It is technically a regression, but the feature still exist and I doubt it’s done much anyway.

+1, also for all LTS branches

iiuc, admins can still edit web.xml to add back the old behavior.
If that’s indeed the case, we can document that (and explain why it’s not a good idea).

In this case, +1 for all branches.

Yes indeed, If the vote pass I will check if we have any kind of documentation related to the Main.DocumentDoesNotExist page and explain one more step is required (if I cannot find anything, I’m not sure it worth starting documenting something we don’t recommend).

1 Like

Same on my side.

4 +1 for master and 3 for LTS, it’s now applied with Loading....