In your error page, the variable "exception" is set to the exception
(if any). You can get the error message and stack trace from the
exception like this:

<p>Exception message: <%= (exception == null) ? "" :
exception.getMessage() %></p>
<%
String stStack = "";
if (exception != null) {
        java.io.StringWriter sw = new java.io.StringWriter();
        exception.printStackTrace(new java.io.PrintWriter(sw));
        stStack = sw.toString();
}
%>
<p>Stack trace:</p>
<pre>
<%= stStack %>
</pre>

(Note: For clarity I omitted some important stuff like sanitizing the
output to prevent people from stuffing nasty HTML/Javascript into the
error messages.)
-- 
Len



On Wed, Aug 20, 2008 at 10:08, Tom van Wietmarschen
<[EMAIL PROTECTED]> wrote:
> L.S,
>
> I'm running tomcat to serve out XML to a custom client (not a webbrowser).
> In order to show an error page that this client can actually display I use
> custom error pages in Tomcat. For this I have specified a JSP as an error
> page, this works very well. However, during the test phase of our project
> I'd also like to add the stacktrace to the error document and optionally to
> a logfile. Since the client cannot interpret a normal HTML page, the
> standard 500 error page that comes with Tomcat is unusable. How can I access
> the stacktrace/error message from my own JSP or a servlet so I can output it
> to our own custom XML format and our testers can give proper feedback. I did
> some googling for this but it seems like everyone else is just trying to get
> rid of the stacktrace instead of changing it.
>
> Sincerely,
>   Tom van Wietmarschen
> --
>
> **Tom van Wietmarschen**
> Software Engineer
>
> Service2Media B.V.
> Vreelandseweg 7
> 1216 CG Hilversum
>
> Capitool 41           7521 PL Enschede
>
> Tel  +31 (0)35 626 46 12
> Fax +31 (0)35 626 46 13
> www.service2media.com <http://www.service2media.com>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to