Printing stack trace in jsp

Im trying to print the stack trace in JSP, the below does not work, how do i achieve the same effect?

}
catch(Exception e)
{
      out.print(e.printStackTrace());      
}
danBoshAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

danBoshAuthor Commented:
also how do i pass excpetions that are caused in a java bean to the browser
0
TimYatesCommented:
Does:

e.printStackTrace( out ) ;

work?
0
TimYatesCommented:
>  also how do i pass excpetions that are caused in a java bean to the browser

throw the exception in the JavaBean, and catch it in the JSP
0
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

TimYatesCommented:
You may need to do:

catch(Exception e)
{
    out.println( "<pre>" ) ;
    e.printStackTrace( out ) ;    
    out.println( "</pre>" ) ;
}
0
kennethxuCommented:
>> e.printStackTrace( out ) ;
this won't always work. because out is JspWriter by spec. use this:

e.printStackTrace( new java.io.PrintWriter( out ) );
0
cpuburstCommented:
To trap errors, you can specify errorpage entries in the web.xml file. Specify the error page you want to forward the error to . Javabean should throw an exception . Automatically the error page will be called.
You have an implicit object exception in the error page alone. Use that to print exceptions.

If you need more details let me know.

regards
cpuburst
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.