7

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

pnuts
  • 58,317
  • 11
  • 87
  • 139
codefinger
  • 10,088
  • 7
  • 39
  • 51

1 Answers1

7

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.

lucrussell
  • 5,032
  • 2
  • 33
  • 39