views:

164

answers:

1

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

+2  A: 

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.

lrussell
You can by the way display the message in JSP/EL by `${exception.message}`.
BalusC