The server level ErrorHandler is a good place to start.

But as you discovered, each WebAppContext also has its own
ErrorPageErrorHandler.

That means each WebAppContext would need a configuration (in XML works!) to
turn off the display of stacks.

Another option is to not use the ErrorHandler default error display, and
just set the global error-page to your servlet.

Yet another option is to use the DeploymentManager and
WebAppProvider's defaultDescriptor configuration to specify the default
global error-page that each WebAppContext will use, obviously pointing to
your servlet.

As yet another solution, you can create your own ErrorHandler and
ErrorPageErrorHandler implementations (just extend from those as needed).
Override the `protected void writeErrorPage(HttpServletRequest request,
Writer writer, int code, String message, boolean showStacks)` method and
set the showStacks to false when you call super.writeErrorPage ...

Joakim Erdfelt / joa...@webtide.com


On Wed, Jun 29, 2022 at 2:55 AM Lothar Kimmeringer <j...@kimmeringer.de>
wrote:

> Hi,
>
> I'm wondering how to get Jetty to omit stack traces in error pages
> globally (programmatically). I've tried to get the Server's
> ErrorHandler before start up, after startup and by setting my
> own in order to set showStack(false). But this has no effect
> #on added web applications where own ErrorHandlers are set that
> still show stack traces.
>
> Before I start to write a method recursively going through
> the whole server searching for error handlers, what's the
> "official" way of getting this configured? The documentation
> I've found so far only shows how to set custom error handlers
> or simply says that an error handler can be set to the server
> and to contexts.
>
>
> Thanks and cheers, Lothar
> _______________________________________________
> jetty-users mailing list
> jetty-users@eclipse.org
> To unsubscribe from this list, visit
> https://www.eclipse.org/mailman/listinfo/jetty-users
>
_______________________________________________
jetty-users mailing list
jetty-users@eclipse.org
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/jetty-users

Reply via email to