codefinger
codefinger

Reputation: 10318

How do I hide stack traces in the browser (using Jetty)?

I'm using Jetty as my servlet container. If an exception is thrown in one of my servlets the browser will display an HTTP ERROR 500 with the exception message and a stack trace.

For security reasons I need to hide the stack trace. Is there a way to configure this generally? Or do I need to trap all Throwables in my Servlet?

Thanks

Upvotes: 7

Views: 4938

Answers (1)

lucrussell
lucrussell

Reputation: 5160

You can set up a custom error page in your web.xml file, with something like this:

<error-page>  
  <error-code>500</error-code>  
  <location>/WEB-INF/jsps/errors/error.jsp</location>  
</error-page> 

Then in your error.jsp, display a custom message and don't show the stacktrace.

Upvotes: 7

Related Questions