Printing stack trace in jsp

Posted on 2003-11-25
Last Modified: 2010-05-18
Im trying to print the stack trace in JSP, the below does not work, how do i achieve the same effect?

catch(Exception e)
Question by:danBosh

Author Comment

ID: 9816908
also how do i pass excpetions that are caused in a java bean to the browser
LVL 35

Expert Comment

ID: 9816999

e.printStackTrace( out ) ;

LVL 35

Expert Comment

ID: 9817000
>  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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

LVL 35

Expert Comment

ID: 9817010
You may need to do:

catch(Exception e)
    out.println( "<pre>" ) ;
    e.printStackTrace( out ) ;    
    out.println( "</pre>" ) ;
LVL 14

Expert Comment

ID: 9822149
>> e.printStackTrace( out ) ;
this won't always work. because out is JspWriter by spec. use this:

e.printStackTrace( new out ) );

Accepted Solution

cpuburst earned 40 total points
ID: 9950647
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.


Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
constructor overloading 2 86
withoutString  challenge 40 208
print map entry 34 72
tomcat startup error 5 105
If you are looking at this article, you have most likely been hit by some version of ransomware and are trying to find out if there is anything you can do, or what way you should react - READ ON!
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

827 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question