Return-Path: Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 83873 invoked from network); 12 Feb 2001 03:03:26 -0000 Received: from dragon.realtime.net (HELO bga.com) (205.238.128.89) by h31.sny.collab.net with SMTP; 12 Feb 2001 03:03:26 -0000 Received: from bga.com ([205.238.179.19]) by bga.com ; Sun, 11 Feb 2001 21:03:33 -0600 Message-ID: <3A87529E.CD6E6297@bga.com> Date: Sun, 11 Feb 2001 21:03:58 -0600 From: William Brogden Organization: Barely organized X-Mailer: Mozilla 4.61 [en] (WinNT; I) X-Accept-Language: en MIME-Version: 1.0 To: tomcat-user@jakarta.apache.org Subject: Re: errorpage.jsp: Can't convert javax.servlet.jsp.JspWriter to java.io.PrintWriter References: <3A872A24.73E610A5@lbl.gov> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N 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"%> >

The following error has been detected:

> > <%= exception %> > > <% 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