Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 968
codefinger Avatar asked Feb 11 '10 16:02

codefinger


People also ask

How do I capture a stack trace?

Get a Stack Trace Using the Thread Class We can obtain a stack trace from a thread by calling the getStackTrace() method on the Thread instance. It returns an array of StackTraceElement, from which details about stack frames of the thread can be found.

What does a stack trace show?

A stack trace shows the call stack (sets of active stack frames) and provides information on the methods that your code called. Usually, a stack trace is shown when an Exception is not handled correctly in code. (An exception is what a runtime environment uses to tell you that there's an error in your code.)

What is stack trace web?

In computing, a stack trace (also called stack backtrace or stack traceback) is a report of the active stack frames at a certain point in time during the execution of a program.


1 Answers

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.

like image 74
lucrussell Avatar answered Sep 20 '22 11:09

lucrussell