# Get rid of the auto Servlet redirect in case of 404

**URL:** <https://forum.xwiki.org/t/get-rid-of-the-auto-servlet-redirect-in-case-of-404/17293>\
**Category:** Development\
**Tags:** proposal\
**Created:** [July 28, 2025, 3:07pm UTC](https://forum.xwiki.org/t/get-rid-of-the-auto-servlet-redirect-in-case-of-404/17293 "2025-07-28T15:07:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tmortagne](https://forum.xwiki.org/user_avatar/forum.xwiki.org/tmortagne/32/4930_2.png) [@tmortagne](https://forum.xwiki.org/u/tmortagne)\
**Post date:** [July 28, 2025, 3:07pm UTC](https://forum.xwiki.org/t/get-rid-of-the-auto-servlet-redirect-in-case-of-404/17293/1 "2025-07-28T15:07:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MichaelHamann](https://forum.xwiki.org/user_avatar/forum.xwiki.org/michaelhamann/32/3813_2.png) [@MichaelHamann](https://forum.xwiki.org/u/MichaelHamann)\
**Post date:** [July 28, 2025, 3:09pm UTC](https://forum.xwiki.org/t/get-rid-of-the-auto-servlet-redirect-in-case-of-404/17293/2 "2025-07-28T15:09:11Z")

</div>

+1, also for all LTS branches

---

<div class="post-metadata">

**Author:** ![mleduc](https://forum.xwiki.org/user_avatar/forum.xwiki.org/mleduc/32/2328_2.png) [@mleduc](https://forum.xwiki.org/u/mleduc)\
**Post date:** [July 28, 2025, 3:14pm UTC](https://forum.xwiki.org/t/get-rid-of-the-auto-servlet-redirect-in-case-of-404/17293/3 "2025-07-28T15:14:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tmortagne](https://forum.xwiki.org/user_avatar/forum.xwiki.org/tmortagne/32/4930_2.png) [@tmortagne](https://forum.xwiki.org/u/tmortagne)\
**Post date:** [July 28, 2025, 3:50pm UTC](https://forum.xwiki.org/t/get-rid-of-the-auto-servlet-redirect-in-case-of-404/17293/4 "2025-07-28T15:50:30Z")

</div>

> [@mleduc](#):
>
> 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).

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).

---

<div class="post-metadata">

**Author:** ![mflorea](https://forum.xwiki.org/user_avatar/forum.xwiki.org/mflorea/32/49_2.png) [@mflorea](https://forum.xwiki.org/u/mflorea)\
**Post date:** [August 5, 2025, 4:08pm UTC](https://forum.xwiki.org/t/get-rid-of-the-auto-servlet-redirect-in-case-of-404/17293/5 "2025-08-05T16:08:22Z")

</div>

> [@MichaelHamann](#):
>
> +1, also for all LTS branches

Same on my side.

---

<div class="post-metadata">

**Author:** ![tmortagne](https://forum.xwiki.org/user_avatar/forum.xwiki.org/tmortagne/32/4930_2.png) [@tmortagne](https://forum.xwiki.org/u/tmortagne)\
**Post date:** [August 5, 2025, 4:26pm UTC](https://forum.xwiki.org/t/get-rid-of-the-auto-servlet-redirect-in-case-of-404/17293/6 "2025-08-05T16:26:03Z")

</div>

4 +1 for master and 3 for LTS, it’s now applied with [Loading...](https://jira.xwiki.org/browse/XWIKI-23437).
