On the error page, just do: exception.printStackTrace()
Although this begs the question: what is a user going to do with an exception. Why not write the exception to the error log so it is persisted and you can go back to it after a user complains?
And you may want to go to a bit more trouble yet to replace newlines with <br> and such. It might be entertaining to write a PrintStream implementation that does that.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Originally posted by Stan James: And you may want to go to a bit more trouble yet to replace newlines with <br> and such. It might be entertaining to write a PrintStream implementation that does that.
I know this is a fairly old thread, but just wanted to share what I could put together from the info presented here. We defined a default error page and put the stack trace "hidden" from the user. In dev/test environments, we can right-click the page and show the source code to see the stack trace.
<div id="stacktrace" style="display:none;"> <pre> <% // if there is an exception if (exception != null) { // print the stack trace hidden in the HTML source code for debug exception.printStackTrace(new PrintWriter(out)); } %> </pre> </div> </pre></blockquote>