aspose file tools*
The moose likes JSP and the fly likes ex.printStackTrace() to String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "ex.printStackTrace() to String" Watch "ex.printStackTrace() to String" New topic
Author

ex.printStackTrace() to String

Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
Hi guys,

I need to convert a ex.printStackTrace into a String so that it can be used in a SQL query to insert it into a table.

This needs to be done from a JSP (inside a try/catch)

Any clues?

Cheers
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Look at:

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Throwable.html#getStackTrace()


All throwables have the getStackTrace method which returns an array of StackTraceElement. You can iterate through that array and build a string with any of the the properties that you like.

Even better, you can put each property into it's own table row.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10285
    
169

Try this out:



[My Blog] [JavaRanch Journal]
Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
Cheers guys, I went for the secoind option in the end. works a treat, even get the formatting back when returning SQL results.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ex.printStackTrace() to String