tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From William Brogden <wbrog...@bga.com>
Subject Re: errorpage.jsp: Can't convert javax.servlet.jsp.JspWriter to java.io.PrintWriter
Date Mon, 12 Feb 2001 03:03:58 GMT


Jason Novotny wrote:
> 
>     I've been learning JSP with this great book from manning.com and
> I've been trying to write an error page. According to the book, I should
> be able to do the following:
> 
> <%@ page isErrorPage="true"%>
> <h1>The following error has been detected:</h1>
> 
> <b><%= exception %></b<br>
> 
> <% exception.printStackTrace(out); %>
> 
>     However, when I try this I get the following:
> 
> gpdk/_0002fjsp_0002ferror_0002ejsperror_jsp_14.java:143: Incompatible
> type for method. Can't convert javax.servlet.jsp.JspWriter to
> java.io.PrintWriter.
>                  exception.printStackTrace(out);
>                                            ^
> 1 error
> 
>     What's the secret to printing a stack trace to the page?

You can't cast the JspWriter to a PrintWriter so what you
have to do is create a StringWriter, use that to make a PrintWriter
and print the stack trace to it. Then just use the toString()
method of StringWriter to get a single string with the full trace.

-- 
WBB - wbrogden@lanw.com
Java Cert mock exams http://www.lanw.com/java/javacert/
Author of Java Developer's Guide to Servlets and JSP 
ISBN 0-7821-2809-2

Mime
View raw message