Wednesday, August 12, 2009

How can I print the stack trace of an Exception out to my JSP page?

To print a stack trace out to your JSP page, you need to wrap the implicit object 'out' in a printWriter and pass the object to the printStackTrace method in Exception. ie:

// JSP scriptlet
try{
// An Exception is thrown
}catch(Exception e){
e.printStacktrace(new java.io.PrintWriter(out));
}

No comments:

Post a Comment