Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Printing stack trace in jsp

Posted on 2003-11-25
6
Medium Priority
?
561 Views
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)
{
      out.print(e.printStackTrace());      
}
0
Comment
Question by:danBosh
6 Comments
 

Author Comment

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

Expert Comment

by:TimYates
ID: 9816999
Does:

e.printStackTrace( out ) ;

work?
0
 
LVL 35

Expert Comment

by:TimYates
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
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Expert Comment

by:TimYates
ID: 9817010
You may need to do:

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

Expert Comment

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

e.printStackTrace( new java.io.PrintWriter( out ) );
0
 
LVL 1

Accepted Solution

by:
cpuburst earned 160 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.

regards
cpuburst
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Loops Section Overview
Suggested Courses

773 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