Try this:

java.io.StringWriter str = new java.io.StringWriter();
exception.printStackTrace(new java.io.PrintWriter(str));
return str.toString();

(*Chris*)

----- Original Message -----
From: "Christian Roslawski" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, September 07, 2001 5:17 AM
Subject: Re: [JSP-INTEREST] jsp error page in email


> Hi Gamini,
>
> > I have followed with interest Alireza & Richards problem and solutions
> > for capturing stacktrace. I tried the solution suggested by you first
> > using the following code within a JSP page
> >
> >       PipedWriter pipeOut = new PipedWriter();
> >       PipedReader pipeIn = new PipedReader(pipeOut);
> >       exception.printStackTrace(new PrintWriter(pipeOut));
> >       BufferedReader br = new BufferedReader(pipeIn);
> >       String inputStr;
> >       while((inputStr = br.readLine()) != null)
> >       ...and so on.
> > The program breaks down while attempting
> >       exception.printStackTrace(new PrintWriter(pipeOut));
> >
> > I wonder what I am doing wrong?
> > Any help would be much appreciated.
>
> Uhm, forget that, it was a silly idea from me to use both ends of a pipe
> in the same thread, sorry. Lacking better ideas I suggest to use the other
> suggested solution with a temporary file:
>
>   File tmpFile = File.createTempFile("exc", "tmp");
>
>   PrintWriter tmpOut = new PrintWriter(new FileWriter(tmpFile), false);
>   exception.printStackTrace(tmpOut);
>   tmpOut.close();
>
>   BufferedReader tmpIn = new BufferedReader(new FileReader(tmpFile));
>   StringBuffer stackTrace = new StringBuffer();
>   String line;
>   while((line = tmpIn.readLine()) != null)
>   {
>     stackTrace.append(line);
>     stackTrace.append("\n");
>   }
>   tmpIn.close();
>
>   tmpFile.delete();
>
>   // send email with the stackTrace...
>
> This requires write access on the system's tmp dir, which you might
> have to add to the secutity policy if your jsp/servlet-container is
> using one. You can also choose a different directory, of course.
>
>   Chris
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to